I need to do something when the user presses only enter without any input but that empty. When the user's input is something, \0 is always right behind the last char. For example
input:hello world
\0 is always in prom[11] but when user press only enter \0 isn't there.
char prom[100];
scanf("%[^\n]", prom);
if (prom[0] == '\0'){ //if user press enter
//do something
}
fgets(or even better,getline, but not all systems provide that) instead ofscanf.scanfhas a matching failure then the contents of the array are indeterminate...