Thread: C Program... Program or Compiler error?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    That code is completely different. Now you don't have braces after the for loop, so the only line that is looped over is:
    Code:
    *walker = *(walker + 1);
    Please post your exact code. I get the feeling you are modifying what you are pasting here.
    bit∙hub [bit-huhb] n. A source and destination for information.

  2. #2
    Registered User
    Join Date
    Dec 2009
    Posts
    8
    Yeah I changed it because I don't know which way is right.
    The goal of the problem is to use pointer notation to write a loop to rotate all values in a to the left by one element.
    I changed it again below just a little because I'm pretty sure it's how it should work.

    Thank you for your help.

    Code:
    #include <stdio.h>
    
    
    int main (void)
    {
    // Local Declarations
    char temp;
    char a[6] = {'z', 'x', 'm', 's', 'e', 'h'};
    char* walker;
    char* plast;
    
    // Statements
    
    plast = a + 5;
    temp = *a;
    
    printf("Array before: %c %c %c %c %c %c\n", 'z', 'x', 'm', 's', 'e', 'h');
    
    printf("Array after: ");
    
    for (walker = a; walker < plast; walker++)
        *walker = *(walker + 1);
    *walker = temp;
    printf (" %c", temp);
    
    fflush(stdout);
    
    getch();
    return 0;
    
    }//main

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM