Scanf Issues

So I got stuck while using eclipse so I switched over to Microsoft studio.But now im having problems in microsoft studio hopefully you guys can help.
Microsoft studio
1
2
3
4
5
6
7
8
9
10
11
 #include <stdio.h>
#include <stdlib.h>
#define ARR_SIZE 10

int main(void) {
	char Name[ARR_SIZE];
	printf_s("Please enter your name:");
	scanf_s("%s", Name);
	printf_s("test %s \n", Name);
	return 0;
}

so it will do either one of two things for the output
either it will shoot out nothing for name or it will output a random character

Now This is the eclipse file
1
2
3
4
5
6
7
8
9
10
11
12
 #include <stdio.h>
#include <stdlib.h>

int main(void) {
	char Name[10];
	printf("Please enter your name:");
	scanf("%s",Name);
	printf("Hello %s",Name);

	return 0;
}


this one more or less works but it doesnt show the printf outputs in the console until I write in the name.

thanks for the help
Try taking the second code and sticking a fflush(stdout); between lines 6 and 7.
do i have to do this everytime i use printf and scan f?
Topic archived. No new replies allowed.