#include <stdio.h>
int main(){
int i;
char name[10],surname[10],id[12],dpart[20];
printf("******** ID Documentation ***********\n\n\n");
printf("1) What is your Name? \n");
scanf("%s",&name);
printf("2) What is your Surname? \n");
scanf("%s",&surname);
printf("3) What is your ID Number \n");
scanf("%s",&id);
printf("4) What is your Department? \n");
scanf("%[^\n]",&dpart);
system("CLS");
for(i=0;i<50;i++){printf("*");}printf("\n");
printf("|");
for(i=0;i<48;i++){printf("%%");}
printf("|");printf("\n");printf("|");
for(i=0;i<14;i++){printf("%%");}
printf(" STUDENT ID CARD ");for(i=0;i<17;i++){printf("%%");}printf("|\n");printf("|");
for(i=0;i<48;i++){printf("%%");}
printf("|\n");
printf(" //////// NAME: %6s ",name);for(i=0;i<26;i++){printf("/");}printf(" \n|");for(i=0;i<48;i++){printf("-");}printf("|\n");
printf(" //////// SURNAME: %6s ",surname);for(i=0;i<23;i++){printf("/");}printf(" \n|");for(i=0;i<48;i++){printf("-");}printf("|\n");
printf(" //////// ID NUMVER: %11s ",id);for(i=0;i<16;i++){printf("/");}printf(" \n|");for(i=0;i<48;i++){printf("-");}printf("|\n");
printf(" //////// DEPARTMENT: %22s ",dpart);for(i=0;i<4;i++){printf("/");}printf(" \n|");for(i=0;i<48;i++){printf("-");}printf("|\n");
printf("|");
for(i=0;i<48;i++){printf("%%");}
printf("|");printf("\n");
printf("|");
for(i=0;i<48;i++){printf("%%");}
printf("|");printf("\n");
printf("|");
for(i=0;i<48;i++){printf("%%");}
printf("|");printf("\n");for(i=0;i<50;i++){printf("*");}
}
I was helping one of my friends on his homework. We have to read the department data than display it on a id card, but when it comes to reading department, the program skips it and adds the value entered for id number to department. Ps: I know that using scanf() is a very bad work, but they didn't learned anything else so i cannot suggest using sscanf to him And also don't care the messy code when writing out data, it works