Answer the question
In order to leave comments, you need to log in
C++ why is the scanf function executed before the printf function?
Why (I work in netbeans) in this code, when executing, you need to enter 1 line that is considered, then some other line that does not participate anywhere, and only then output "Enter your name.\n Your name is **** "And I need to enter the name immediately after the question. It turns out that scanf works faster, it's like that in general.
int main(int argc, char** argv) {
setlocale(LC_ALL, "ru_RU.UTF-8");
char *name; //=new char[10];
printf("Введите ваше имя ");
scanf("%s",&name);
printf("\nВаше имя - %s\n",&name);
//system("pause");
return 0;
}
int main(int argc, char** argv) {
setlocale(LC_ALL, "ru_RU.UTF-8");
char buffer[100]; // массив (буфер) для вводимой строки
gets(buffer); // вводим строку и нажимаем enter
printf("%s",buffer);
//system("pause");
return 0;
}
Answer the question
In order to leave comments, you need to log in
It turns out that scanf works faster, it's like that in general.
fflush(stdout)
after printf
:printf("Введите ваше имя ");
fflush(stdout);
scanf("%s",name);
char *name; //=new char[10]; ... scanf("%s",&name);
char name[10];
...
scanf("%s",name);
char *name = new char[10];
...
scanf("%s",name);
1. think for yourself, look, if this path is easy, then why not? and what for you to think about - "Does it make sense to get into such "constructors" at all?" - it’s the same as you wrote above, only for the thesis, I don’t see the point in going especially deep into the rabbit hole
2. make a website and simply open this website in your application using the webiew component on other sites too). Maximum 2-4 lines in java, and everything else - html/css/js
3. startandroid.ru
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question