1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Character Stufing

Discussion in 'C' started by bsudhir6, Apr 4, 2010.

  1. bsudhir6

    bsudhir6 New Member

    Joined:
    Apr 4, 2010
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    I wrote a C program implementing charecter stuffing i'm providing a file contains everything i've followed to write the program i need someone solve the errors

    View attachment Charecter Stuffing.pdf
     
  2. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    1) post your code properly and not to a locked pdf document(copy forbidden)
    2) int main() never void!!!
    3) printf("Enter the input string"); not prinft
    4) for (i=4;i<l;){
    then you say tmp[i+3]==...
    last value of i=l-1 so i+3=l-1+3=l+2
    but l=strlen(temp) so last value of temp is temp[l-1]
    all this result segmentation fault!
    the correct for-->for (i=4;i<l-3;i++){


    correct these errors,and post properly the new code for the rest.
     
  3. bsudhir6

    bsudhir6 New Member

    Joined:
    Apr 4, 2010
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
  4. bsudhir6

    bsudhir6 New Member

    Joined:
    Apr 4, 2010
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Sir i want to know when the return types to main functions are must be changed
     
  5. bsudhir6

    bsudhir6 New Member

    Joined:
    Apr 4, 2010
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    But sir I don't need to chang the values of i,l???
     
  6. bsudhir6

    bsudhir6 New Member

    Joined:
    Apr 4, 2010
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    Means i=i+8,l=l+4
     
  7. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Never. main always returns int, and you should return either the constant EXIT_SUCCESS, or the value 0, unless you have a good reason for doing otherwise (for example if you want to return an error code to a calling script).

    There are exceptions for some compilers, for example the MikroElektronika compilers typically take void for main, but that's because there's nothing to return to: when main returns, the PIC chip has nothing else to do but halt. Maybe OS writers get to use void main too, for the same reason.

    Valid main prototypes unless you have a good *technical* reason to use otherwise, are therefore:

    int main()
    int main(int argc)
    int main(int argc, char **argv)
    int main(int argc, char **argv, char **envp)

    and you should always use one of these four.
     

Share This Page