scanf Use details
int num1;
scanf ("%i", &num1);
int num1,num2;
printf ("Please enter 2 numbers:");
scanf ("%i%i", &num1,&num2);
Description
A input data type (%i%i) If there is no spacer, the default is to use table, carriage return, space to do the spacer
B can be clearly between%i%i with what symbol to make the spacer, such as%i,%i is to do with a comma input spacer, at this time in the use of table, carriage return, space is not working.
- Pay special attention to the input char type data
int num1,num2;
char c;
printf ("Please enter 1 digits, 1 letters, 1 digits:");
scanf ("%i%c%i", &num1,&c,&num2);
At this point, if the table, carriage return, space to do the spacer, the data output is wrong. You can now direct the number + character + number (for example: 2#3), without any spacer, or use the specified spacer (2,#,3 at this time the comma is the spacer).
Use of scanf (Xcode development environment)