NO

Author Topic: error #2048: Undeclared identifier 'i'.  (Read 5296 times)

net2011

  • Guest
error #2048: Undeclared identifier 'i'.
« on: December 09, 2011, 05:56:03 AM »
When I try to run the following code I get "error #2048: Undeclared identifier 'i'.". Here is the code.

#include <stdio.h>

int main()
{
   i = 0;

   while (i < 10)
   {
      printf("i is now %d!\n", i);
      i++;
   }

   printf("All done!\n");
}

Thanks for the help.

CommonTater

  • Guest
Re: error #2048: Undeclared identifier 'i'.
« Reply #1 on: December 09, 2011, 06:12:49 AM »
When I try to run the following code I get "error #2048: Undeclared identifier 'i'.". Here is the code.
Code: [Select]
#include <stdio.h>

int main( void )
{
      int i = 0;

      while (i < 10)
       {
          printf("i is now %d!\n", i);
          i++;
      }

      printf("All done!\n");
      return 0;
}

Simply saying i=0; does not give the variable a type.
 

net2011

  • Guest
Re: error #2048: Undeclared identifier 'i'.
« Reply #2 on: December 09, 2011, 05:26:02 PM »
Boy, I feel pretty silly now. Thanks for the help.

CommonTater

  • Guest
Re: error #2048: Undeclared identifier 'i'.
« Reply #3 on: December 09, 2011, 06:44:20 PM »
Boy, I feel pretty silly now. Thanks for the help.

No worries. 

And don't feel silly.  If you aren't making mistakes you aren't learning anything new!