Skip to main content
added 299 characters in body
Source Link
zubergu
  • 3.7k
  • 4
  • 28
  • 39

In here:

printf("Do you wish to continue?\n");
    scanf(" &c", &cont);
    wipe_buffer();
    }while(cont == 'y' || cont == 'Y');

there should be:

scanf(" %c", &cont);

Compile with -Wall -pedantic options next time you face some problem(if you use gcc). It shows nicely where the problem lies, and if not - it narrows it down a little.

That's what it shows in your case:

test2.c:117:5: warning: too many arguments for format [-Wformat-extra-args]
test2.c:120:1: warning: control reaches end of non-void function [-Wreturn-type]

so it's also a nice reminder that your main() function has to return some value.

Another suggestion is to rad through this link:http://www.gidnetwork.com/b-60.html and follow to The Steps page.
To make it short - there's some information on how time and space consuming is reading one char from stdin with scanf in comparison to getchar.
Consider applying this suggestion in your code.

In here:

printf("Do you wish to continue?\n");
    scanf(" &c", &cont);
    wipe_buffer();
    }while(cont == 'y' || cont == 'Y');

there should be:

scanf(" %c", &cont);

Compile with -Wall -pedantic options next time you face some problem(if you use gcc). It shows nicely where the problem lies, and if not - it narrows it down a little.

That's what it shows in your case:

test2.c:117:5: warning: too many arguments for format [-Wformat-extra-args]
test2.c:120:1: warning: control reaches end of non-void function [-Wreturn-type]

so it's also a nice reminder that your main() function has to return some value.

In here:

printf("Do you wish to continue?\n");
    scanf(" &c", &cont);
    wipe_buffer();
    }while(cont == 'y' || cont == 'Y');

there should be:

scanf(" %c", &cont);

Compile with -Wall -pedantic options next time you face some problem(if you use gcc). It shows nicely where the problem lies, and if not - it narrows it down a little.

That's what it shows in your case:

test2.c:117:5: warning: too many arguments for format [-Wformat-extra-args]
test2.c:120:1: warning: control reaches end of non-void function [-Wreturn-type]

so it's also a nice reminder that your main() function has to return some value.

Another suggestion is to rad through this link:http://www.gidnetwork.com/b-60.html and follow to The Steps page.
To make it short - there's some information on how time and space consuming is reading one char from stdin with scanf in comparison to getchar.
Consider applying this suggestion in your code.

added 301 characters in body
Source Link
zubergu
  • 3.7k
  • 4
  • 28
  • 39

In here:

printf("Do you wish to continue?\n");
    scanf(" &c", &cont);
    wipe_buffer();
    }while(cont == 'y' || cont == 'Y');

there should be:

scanf(" %c", &cont);

Compile with -Wall -pedantic options next time you face some problem(if you use gcc). It shows nicely where the problem lies, and if not - it narrows it down a little.

That's what it shows in your case:

test2.c:117:5: warning: too many arguments for format [-Wformat-extra-args]
test2.c:120:1: warning: control reaches end of non-void function [-Wreturn-type]

so it's also a nice reminder that your main() function has to return some value.

In here:

printf("Do you wish to continue?\n");
    scanf(" &c", &cont);
    wipe_buffer();
    }while(cont == 'y' || cont == 'Y');

there should be:

scanf(" %c", &cont);

Compile with -Wall -pedantic options next time you face some problem(if you use gcc). It shows nicely where the problem lies, and if not - it narrows it down a little.

In here:

printf("Do you wish to continue?\n");
    scanf(" &c", &cont);
    wipe_buffer();
    }while(cont == 'y' || cont == 'Y');

there should be:

scanf(" %c", &cont);

Compile with -Wall -pedantic options next time you face some problem(if you use gcc). It shows nicely where the problem lies, and if not - it narrows it down a little.

That's what it shows in your case:

test2.c:117:5: warning: too many arguments for format [-Wformat-extra-args]
test2.c:120:1: warning: control reaches end of non-void function [-Wreturn-type]

so it's also a nice reminder that your main() function has to return some value.

Source Link
zubergu
  • 3.7k
  • 4
  • 28
  • 39

In here:

printf("Do you wish to continue?\n");
    scanf(" &c", &cont);
    wipe_buffer();
    }while(cont == 'y' || cont == 'Y');

there should be:

scanf(" %c", &cont);

Compile with -Wall -pedantic options next time you face some problem(if you use gcc). It shows nicely where the problem lies, and if not - it narrows it down a little.