Thread: strings

  1. #1
    Unregistered
    Guest

    strings

    i have this code but i can't get it to compile

    #include <stdio.h>
    #include <stdlib.h>

    char reverse(char *A);

    int main()
    {
    char buffer1[] = {'t','h','i','s',' ','i','s',' ','t','h','e',
    ' ','f','i','r','s','t',' ','b','u','f','f','e','r','/0'};

    char buffer2[] = "this is the second buffer";

    char buffer3[80];

    char *pbuffer = buffer3;

    printf("Enter a string: ");
    scanf("%s", buffer3);


    printf("%s\n", buffer1);
    printf("%s\n", buffer2);
    printf("%s\n", buffer3);

    do
    {
    printf("%s", *pbuffer);
    *pbuffer++;
    }
    while(*pbuffer != '/0');

    reverse [buffer3];
    printf("%s\n", buffer3);

    return 0;
    }

    char reverse (char *A)
    {
    char temp;

    char *pfirst = A;
    char *plast= A;

    while(*plast !'\0')
    {
    plast ++;
    }
    plast --;

    while(pfirst<plast)
    {
    temp = *pfirst;
    *pfirst = *plast;
    *plast = temp;

    pfirst ++;
    plast --;
    }
    return char *A;
    }

  2. #2
    Unregistered
    Guest

    these are the errors

    cc-1069 cc: WARNING File = lab8.c, Line = 9
    Integer conversion resulted in truncation.

    ' ','f','i','r','s','t',' ','b','u','f','f','e','r','/0'};
    ^

    cc-1178 cc: WARNING File = lab8.c, Line = 27
    Argument is incompatible with the corresponding format string conversion.

    printf("%s", *pbuffer);
    ^

    cc-3316 cc: ERROR File = lab8.c, Line = 32
    The expression must be a pointer to a complete object type.

    reverse [buffer3];
    ^

    cc-1031 cc: ERROR File = lab8.c, Line = 32
    An integral expression is needed.

    reverse [buffer3];
    ^

    cc-1018 cc: ERROR File = lab8.c, Line = 45
    An unmatched left parentheses "(" appears in an expression.

    while(*plast !'\0')
    ^

    cc-1029 cc: ERROR File = lab8.c, Line = 60
    An expression is expected at this point.

    return char *A;
    ^

    4 errors detected in the compilation of "lab8.c".
    (50)%

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    See my reply to your other thread. For future refrence, just keep posting in the same thread, stop making multiple posts with different topics that are all the same issue.

    > char reverse (char *A)

    This is probably supposed to be:

    char *reverse( char *A )
    {
    ....do stuff...

    return A;
    }


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 02:09 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM