Problem with switch loop

This is a discussion on Problem with switch loop within the C Programming forums, part of the General Programming Boards category; I'm having some trouble with this switch loop: Code: switch (guess_counter) { case 1; strcpy (recent_guess1, user_input); guess_counter++; break; case ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    24

    Problem with switch loop

    I'm having some trouble with this switch loop:

    Code:
    switch (guess_counter)
    	{
    		case 1;
    			strcpy (recent_guess1, user_input);
    			guess_counter++;
    			break;
    		case 2;
    			strcpy (recent_guess2, user_input);
    			guess_counter++;
    			break;
    		case 3;
    			strcpy (recent_guess3, user_input);
    			guess_counter++;
    			break;
    		default;
    			strcpy (recent_guess4, user_input);
    			guess_counter = 1;
    			break;
    	}
    When i compile, i get this error:
    mastermind2.c: In function `update_recent':
    mastermind2.c:156: error: parse error before ';' token
    mastermind2.c:160: error: parse error before ';' token
    mastermind2.c:164: error: parse error before ';' token
    mastermind2.c:168: error: parse error before ';' token

    I have tried evrything i can think of and can't see why this is happening, does anyone have any ideas?

    Many Thanks

  2. #2
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Its:
    Code:
    case 1:

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,622
    Btw, this is a switch and not a "switch loop". You don't see it looping anywhere, do you?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    24
    well that was a stupid mistake,

    Thanks for fixing that!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with a loop
    By wiggsfly in forum C Programming
    Replies: 5
    Last Post: 11-30-2008, 11:45 AM
  2. whats the problem....
    By vapanchamukhi in forum C Programming
    Replies: 3
    Last Post: 09-05-2008, 12:19 PM
  3. Problem with loop
    By sweetorangepie in forum C Programming
    Replies: 6
    Last Post: 03-24-2008, 04:53 PM
  4. Infinte loop with switch, Why??
    By Kate in forum C Programming
    Replies: 8
    Last Post: 06-16-2005, 02:15 AM
  5. problem with printing a structed array using for loop
    By Prezo in forum C++ Programming
    Replies: 2
    Last Post: 09-15-2002, 09:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21