ok '&' is the one which give u the address, think of something like this
scanf the syantx is as follow
when u say _________
&i --> it gives you the address of 'i' i.e where the 'i' is located in the memory | |
so when u say &i --> it gives you the address of 'i ' in this case it is 1000
scanf function always requires address of the variable in order to place the value entered by the user. u are expected to specilfy '&' in front of the variable. in your case
scanf("const char format", ... varibale);
the scanf is expecting the address of the variable ch to place u'r char eneted in the memory
>Upon running the program, I enter in the sentence seperated by a spacebar, it would only show the first word! How do I make it so it takes the whole sentence?
that is b'cose the scanf() fucntion reads the string up to the white space the rest is lost.
the better way of doing this is to use fgets function to read the string. and this syntax is as follow
fgets(char *, int, FILE *);
hope this helps
fgets(str, sizeof str, stdin); // read the string
printf("%s",str); // print the string on to the screen
/* output: -