When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
25 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
@warped harness
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. You can use !solved to close a post and mark it as solved.
Hello,
does someone know why my code does not ask for any input despite of the "scanf" ?
Thanks !
#include <stdio.h>
#include <stdlib.h>
int main(){
char letter;
int nbLignes;
int occurrences = 0;
scanf("%c", &letter);
scanf("%d", &nbLignes);
for(int i=1;i<=nbLignes;i++){
char ligne[1001];
scanf("%[^\n]\n", ligne);
for (int j=0;ligne[j]!='\0';j++){
if (ligne[j] == letter){occurrences++;}
}
}
printf("%d", occurrences);
return 0;
}
every once in a while this always pops up 
how can I avoid this issue ?
you can make your scanf line like this:
scanf(" %d", &nbLignes);
here is a blog post I wrote about this issue that is common with beginners using scanf
but that does not recup the string
no ?
?
Okk thank, i'm gonna read that now
%d isn't used to recup int inputs ?
"After scanf reads in the number, the newline character stays . . . " what is "the new line character" ?
like
when i scanf my int
it does not go to the next line ?
for now you can understand newline as "when you press the enter key"

!solved