Hi, I've written a Program like this:
If I use the Funktion ausgabe() the Program works (97 Name01, 98 Name02 etc.), but when I use these line of Code instead the Funktion ausgabe().Code:#include <stdio.h> #include <stdlib.h> #define STRING_SIZE 30 struct TestStruct { char id; char name[STRING_SIZE]; }; void ausgabe(struct TestStruct *struct_ptr) { printf(" %d %s!\n\n",(*struct_ptr).id, (*struct_ptr).name); } int main(int argc, char *argv[]) { struct TestStruct test[10]; test[0].id = 0x61; strcpy(test[0].name, "Name01"); test[1].id = 0x62; strcpy(test[1].name, "Name02"); test[2].id = 0x63; strcpy(test[2].name, "Name03"); test[3].id = 0x64; strcpy(test[3].name, "Name04"); int i; for(i=0;i<=5;i++) { //printf("%d %s!\n\n", &test[i].id, &test[i].name); ausgabe(&test[i]); } system("PAUSE"); return 0; }
The Result is that the .id's have some Values like 2686036 or 2686032 etc.Code:printf("%d %s!\n\n", &test[i].id, &test[i].name);
Can some one explain me why this happens?



1Likes
LinkBack URL
About LinkBacks


