i'm new in program
i want to write code in c .. and i'll convert it to c++
but i've problem

this is the code


	typedef struct std
	int id;
	char name [10];
	char status;

void main()

	STD m;
	printf("Enter  id : ");
	printf("\n Enter name : ");
	printf("\n Enter status : ");
	printf("The Day Is : %d / %c / %c ",m.id,m.name,m.status);

Now ,

when i run code , it is run ...
i put id .. ok
the next step is to put name , the program terminated it and ask for status dirct ..
after i put status ..
the info displayed ... but the name deos not appear ..
i guss the problem with " Char Array "
i'm not good with it..
please help me..

Recommended Answers

All 2 Replies

- This is not a C++ question, but a C question.
- Why not to use scanf

If you want to use scanf to get a char array from input, you should use %s instead of %c. Same goes for printf.
So change: scanf("%c",&m.name); to: scanf("%s",&m.name); Make the same change for your printf.

thanks bro
all it's ok ..
thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.