Table of Contents

Warnings

warnings.c:3:2: means in line 3 at char 2 need a solution
to check if you have some errors in your code use for
gcc testcode.c -o testcode -Wall
that will display all Warnings

warning: control reaches end of non-void function

You must add a return value at the end of your sourcecode:

#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
/* code example warnings control reaches end of non-void function
 * http://code-reference.com/c/compiler/gcc/warnings 
 */
int main (void )
{
int i=0;
printf("%i\n",i);
 
/* to fix the warning add for this example "return 0;"
 * warning: control reaches end of non-void function 
 */
//<- here
}

warning: return type defaults to ‘int’

Add a return type to your function:

#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
/* code example warnings return type defaults to ‘int’
 * http://code-reference.com/c/compiler/gcc/warnings 
 *
 * you must add a "int" before and ( void ) after the function
 * for this example
 * change main() to "int main ( void )"
 */
main () // <-- here
{
int i=0;
printf("%i\n",i);
return 0;
}

warning: unused variable ‘i’

Delete some unused variable definitions:

/* code example warnings unused variable
 * http://code-reference.com/c/compiler/gcc/warnings 
 */
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
 
/* change int i,x=0;
 * to 
 * x=0;
 */
int main ( void )
{
int i,x=0; // <-- here
printf("%i\n",x);
return 0;
}

error: ‘i’ undeclared (first use in this function)

warnings.c:10:1: note: each undeclared identifier is reported only once for each function it appears in

You must declare the variable, in this case an integer variable i:

/* code example warnings undeclared identifier 
 * http://code-reference.com/c/compiler/gcc/warnings 
 *add int i;
 */
 
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
 
int main ( void )
{
int x=0; // <-- add here int x=0, i=9;
i=9;
printf("x=%i and i=%i\n",x,i);
return 0;
}