Well those are some nice tricks. Why not explicitly list the arguments for printf though, so the compiler does not have to guess?
What happens if there is more than one string?
Code:
#include <stdio.h>
#include <string.h>
int main ( void )
{
int a;
char name[15];
char string[15];
strcpy(name, "peter");
strcpy(string, "lalalalal");
printf("Hello, %s, how old are you? ");
fflush(stdout);
scanf("%d", &a);
printf("So you are %d years old!\n", a);
return 0;
}
My output: Hello, lalalalal, how old are you?
Now if I change the printf to look like this:
Code:
printf("Hello, %s, how old are you? ", name);
Then I get the expected output:
Hello, peter, how old are you?
And if you know enough to apologise for using getch with conio.h, why don't you know enough not to include it?