try this code
#include <stdio.h>
typedef struct list
{
int data;
struct list *next;
}ll;
main()
{
ll *head,*p;
int temp;
char c;
head=(ll*) malloc(sizeof(struct list));
printf("the data for head:");
scanf("%d",&head->data);
printf("head=:%d",head->data);
printf("enter the value of c:");
fflush(stdin);/* Added here*/
c=getchar();
printf("here:%c",c);
p=head;
system("PAUSE");
return 0;
}
> -----Original Message-----
> From: vasanthsena x [SMTP:vas...@ya...]
> Sent: Saturday, November 22, 2003 6:48 AM
> To: dev...@li...
> Subject: [Dev-C++] another annoying newbie question!!!
>
> Hi I have just started out with structures in C.
> I have written the following program.I try to read in
> a char called c but the program terminates.Can anyone
> help me and tell me why.
>
>
> #include <stdio.h>
>
> typedef struct list
> {
> int data;
> struct list *next;
> }ll;
>
> main()
> {
> ll *head,*p;
> int temp;
> char c;
> head=(ll*) malloc(sizeof(struct list));
>
>
> printf("the data for head:");
>
> scanf("%d",&head->data);
> printf("head=:%d",head->data);
>
> printf("enter the value of c:");
> c=getchar();
> printf("here:%c",c);
>
> p=head;
>
>
> system("PAUSE");
> return 0;
> }
>
>
> thanks.
>
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive? Does it
> help you create better code? SHARE THE LOVE, and help us help
> YOU! Click Here: http://sourceforge.net/donate/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
*********************************************************************
Disclaimer: The information in this e-mail and any attachments is
confidential / privileged. It is intended solely for the addressee or
addressees. If you are not the addressee indicated in this message, you may
not copy or deliver this message to anyone. In such case, you should destroy
this message and kindly notify the sender by reply email. Please advise
immediately if you or your employer does not consent to Internet email for
messages of this kind.
*********************************************************************
|