My first post here. Programming in C. Sorry if this has been answered before, as I wasn't sure how to search for it. I'm wondering why I needed to put a & operator when scanning for an int, but not for a char array. My guess is that it has something to do with storing the int inside the address, as opposed to inside the array, but I don't fully understand.
Here's my code:
#include <stdio.h>
int main(void) {
char user_word[10];
printf("enter a word: ");
scanf("%s", user_word);
printf("%s\n", user_word);
int user_num;
printf("enter a number: ");
scanf("%d", &user_num);
printf("%d\n", user_num);
}
Also, please let me know if I have any bad coding conventions in how it was typed.
Thanks :)