Hi,
I have a question,....he re is my program
o/p is
5500 10
5500 9
5500 8
5500 7
5500 6
5500 5
5500 4
5500 3
5500 2
5500 1
Expected is
1000 10
1500 11
Here TEXT is 4-byte unsigned integer (Character pointers to type TEXT).
Could you please help me to figure out this error? I am just a starter in C.
Hope my question is clear....
Thanks in advance..
I have a question,....he re is my program
Code:
struct list_el { int val; TEXT *acct_no; struct list_el * next; }; typedef struct list_el item; void main() { item * curr, * head; int i; long j = 1000; char ch[4]; head = NULL; for(i=1;i<=10;i++) { curr = (item *)malloc(sizeof(item)); curr->val = i; sprintf(ch,"%ld",j); curr->acct_no = (pTEXT)ch; curr->next = head; head = curr; j += 500; } curr = head; while(curr) { printf("%s \t %d\n", curr->acct_no, curr->val); curr = curr->next ; } free(curr); }
5500 10
5500 9
5500 8
5500 7
5500 6
5500 5
5500 4
5500 3
5500 2
5500 1
Expected is
1000 10
1500 11
Here TEXT is 4-byte unsigned integer (Character pointers to type TEXT).
Could you please help me to figure out this error? I am just a starter in C.
Hope my question is clear....
Thanks in advance..
Comment