Может кто-нибудь может помочь мне с моим кодомВведите имя с (пробел)
void gotoxy(int, int);
void clrscr();
void dispMenu();
int main(void){
int choice;
choice = 0;
menu:
dispMenu();
scanf("%d", &choice);
if(choice==1){
clrscr();
char name[100];
printf("Please Input your Complete name: ");
scanf("%[^\n]s", &name);
printf("Your name is: %s \n", name);
}
getch();
goto menu;
}
void dispMenu(){
gotoxy(23,9);
printf("List of C-Lang Activities\n");
gotoxy(23,11);
printf("1. Input Name");
gotoxy(23,12);
printf("2. (blank) \n");
gotoxy(23,13);
printf("3. (blank) \n");
gotoxy(23,14);
printf("4. (blank)\n");
gotoxy(23,15);
printf("5. (blank)\n");
gotoxy(23,17);
printf("Please Enter the Number of your choice: ");
}
void gotoxy(int x, int y){
HANDLE hConsoleOutput;
COORD dxCursorPosition;
dxCursorPosition.X = x;
dxCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput, dxCursorPosition);
}
void clrscr(){
system("cls");
}
У меня есть проблема, когда я пытаюсь поставить свою программу в меню таблицы это то, что появится:
выход будет как этот
Please Input your Complete Name: John Kenneth
Your Name is: John Kenneth
'зсапЕ ("% [^ \ п] s", &name);' не использовать '& 'здесь и'% ['сам по себе спецификатор, поэтому не ставьте' s' после него. – ameyCU
что я должен использовать? – iCeStar
См. Здесь -http: //www.cplusplus.com/reference/cstdio/scanf/ – ameyCU