I'm trying to write a function that outputs an input string 10 times. Here is the code.
#include <stdio.h>
int print10times(){
char input[] = "";
printf("Which string would you like to print 10 times? ");
scanf("%s", input);
for (int i=0; i<10; i++){
printf("%s\n", input);
}
return 0;
}
int main(){
print10times();
return 0;
}
The output I'm getting looks like this:
Which string would you like to print 10 times? Hello
H
H☺
H☻
H♥
H♦
H♣
H♠
H
H
H
Could someone let me know why this doesn't print "Hello" 10 times?
Thanks.