hi
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

#include<stdio.h>
#include<conio.h>


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

void main()

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

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..

- 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, networking, learning, and sharing knowledge.