Monday, March 16, 2009

Pointer Heroics

I somtime come across code like the following. I wonder if this is ignorance, heroics or just cool. Some compilers flag these as warning but some (specially the embedded) will let it pass. Look at the code and guess what I am talking about

#include
typedef struct _nameString {
char nameStr[64];
char nothing[64];
} nameString;

typedef struct _myName {
nameString lastName;
nameString firstName;
} myName;

main() {
myName name;
printf("Enter the Lastname:");
scanf("%s", &name.lastName);
printf("Last Name is %s\n",name.lastName.nameStr);
}

No comments:

Post a Comment