#include<stdio.h>
struct student{
int a;
char b[45];
};
void main()
{
struct student student1;
printf("Size of struct: %d" ,sizeof(student1));
}
The output in c99 :Size of struct :52
Why is that ?
can u tell me how to create a typedef of a employee of a company having a attribute Name,Emp_ID,Dept Name,Designation..
same as for student of a collage with the attributes Name,Rollno,Section,Branch,Total amrks,Result..
do reply as soon as it is possible..
#include <stdio.h>
#include <stdlib.h>
int MAX;
int count = 0;
struct node {
struct node *next;
int value;
};
void push (struct node ** headref,int k)
{
if( count < MAX ) {
struct node *newnode;
newnode = malloc(sizeof(struct node));
newnode->value = k;
newnode->next = *headref;
*headref = newnode;
count++;
}
else {
printf(" Stack is Full ");
}
}
void pop(struct node * headref)
{ int m;
if (headref == NULL) {
printf(" STACK IS EMPTY ");
exit(0);
}
else
{
m = headref->value;
printf(" POP OUT VALUE %d" ,m);
}
}
int main()
{
struct node *head = NULL;
int val, choice, i,j = 1;
printf(" enter the MAXIMUM size for stack\n ");
scanf(" %d " ,&MAX);
while(j) {
printf(" ENTER THE CASE NUMBER WHICH U WANT TO CHOOSE \n\t 1.FOR PUSH \n\t2.FOR POP\n ");
scanf(" %d ",&choice);
switch(choice) {
case 1:
printf("enter the value to be pushed ");
scanf("%d",&val);
push(&head,val);
break;
case 2:
pop(head);
head = head->next;
break;
default:
printf(" invalid option\n ");
}
printf(" enter the one for continue\n ");
scanf("%d",&j);
}
return 0;
}
when some one ask for the simplest example of ...kindly do'nt use the pointer ....
difne the sturct example ..in a very simple way so that begners cn understand it easily .............
structurerinku sehrawat April 18, 2013 at 10:28 AM
Isn't it Strange?Shiben June 3, 2011 at 12:11 PM
#include<stdio.h> struct student{ int a; char b[45]; }; void main() { struct student student1; printf("Size of struct: %d" ,sizeof(student1)); } The output in c99 :Size of struct :52 Why is that ?
CommentdE_logics June 9, 2011 at 8:12 PM
Sheer stupidity. #include <conio.h> and getch(); It proves you know nothing but Windows.
c Structure examplePiet October 3, 2011 at 6:05 AM
I cannot run the example, because the compilers does not know #include <conio.h> What can I do? thx
C vinay October 6, 2011 at 2:15 PM
I want to how to pass structure variable to function in simple way.
queriy related typedef stuct.mukul kshatriya October 19, 2011 at 6:36 PM
can u tell me how to create a typedef of a employee of a company having a attribute Name,Emp_ID,Dept Name,Designation.. same as for student of a collage with the attributes Name,Rollno,Section,Branch,Total amrks,Result.. do reply as soon as it is possible..
HImohamed rizwan December 15, 2011 at 12:37 PM
Its nice to see many tags for structure i hope this tags may use us in coding our new idea
Stack by pointermadhusudan balai December 21, 2011 at 8:49 PM
#include <stdio.h> #include <stdlib.h> int MAX; int count = 0; struct node { struct node *next; int value; }; void push (struct node ** headref,int k) { if( count < MAX ) { struct node *newnode; newnode = malloc(sizeof(struct node)); newnode->value = k; newnode->next = *headref; *headref = newnode; count++; } else { printf(" Stack is Full "); } } void pop(struct node * headref) { int m; if (headref == NULL) { printf(" STACK IS EMPTY "); exit(0); } else { m = headref->value; printf(" POP OUT VALUE %d" ,m); } } int main() { struct node *head = NULL; int val, choice, i,j = 1; printf(" enter the MAXIMUM size for stack\n "); scanf(" %d " ,&MAX); while(j) { printf(" ENTER THE CASE NUMBER WHICH U WANT TO CHOOSE \n\t 1.FOR PUSH \n\t2.FOR POP\n "); scanf(" %d ",&choice); switch(choice) { case 1: printf("enter the value to be pushed "); scanf("%d",&val); push(&head,val); break; case 2: pop(head); head = head->next; break; default: printf(" invalid option\n "); } printf(" enter the one for continue\n "); scanf("%d",&j); } return 0; }
learn c structure hanumant January 21, 2012 at 1:57 PM
i become perfert in to the structure in c
cv.elango January 25, 2012 at 9:24 AM
palindrome
data structure Amit Godsay February 3, 2012 at 5:36 PM
why linked list is useful than array and send the program of linked list
a doubtjafar sadiq e February 12, 2012 at 6:01 PM
struct student st; in this, what "st" stands for..????
Thanks a lot :DRicachan February 16, 2012 at 9:33 AM
Thanks man! that was simple and very helpful.
csundar February 29, 2012 at 12:39 AM
fill detail about c..
c programbenjamin ansong May 11, 2012 at 7:02 PM
how to use functions in c structures.
doubt in structures in csuresh May 15, 2012 at 2:49 PM
how can i access structure elemnts with out using dot and arrow aoperators
C,C++Mohammed Imtiyaz M June 5, 2012 at 11:18 AM
struct student st; Can any one please explain above statement in detail.
Thanks for providing help about structure in CRahul kumar June 28, 2012 at 9:51 PM
Dear . I am very happy to get knowledge about this structure in C. Thanks.
ask questionsweta agrawal July 10, 2012 at 11:55 AM
please quickly give the answer of the ques.
c programssuresh March 9, 2013 at 8:05 AM
how to solve in oops consept problems
Cpankaj July 17, 2012 at 10:27 AM
good explanation
information of c languagepavithra July 21, 2012 at 2:53 PM
studying c language
structureskrishnakumari August 1, 2012 at 8:00 AM
very nice
help to understand plzshuham September 18, 2012 at 1:59 PM
struct stud { int roll ; char name[10]; struct stud *next; } what that line means 'struct stud *next'
c-structuresDIVYA October 3, 2012 at 4:01 PM
want programme for cheak validation of date
c quizMangesh October 19, 2012 at 4:15 PM
what is the use of getch in c
c progaramabhinaya November 11, 2012 at 11:51 AM
this is good
NO So Badlapta November 22, 2012 at 10:56 AM
Good Attempts
structure in c rahul sharma November 24, 2012 at 12:27 AM
when some one ask for the simplest example of ...kindly do'nt use the pointer .... difne the sturct example ..in a very simple way so that begners cn understand it easily .............
structurerinku sehrawat April 18, 2013 at 10:28 AM
w.a.p for structure record of a student
structure in c???? April 21, 2013 at 6:07 PM
good
Post your Comment