[QUOTE=cse.avinash]pleaser close this thread its too old(4 yrs) now.....[/QUOTE]

Normally I would say the same thing, except that most of the "bump" comments were praising the information on this thread. While that isn't adding anything useful to this thread, it takes effort to browse Google, find this information, and feel so compelled by its influence that they go through the entire DaniWeb registration procedure just to thank the poster.

Also, just to play the devils advocate, you yourself submitted a comment to a 4 year old thread before your comment that no one else should. Ironic.

By the way, 2007 was a great year.

Did you write the driver? If so, welcome to the right forum!

chris5126 commented: your replies just arent helpful -1

I tested this code just to be sure it works. This is a better version of what you were trying to do.
[code]
// This will modify the given string to be cleaned of special characters.
// It will return the given modified cleaned string.

char CleanString(char String) {
char clean = String, // Pointer to the clean part of the string
original = String; // Pointer to the original part of the string

// Go through each character in the original string
for (;original[0]!='\0'; original++) {
switch (original[0]) {
// Rejected Characters
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case '\n': case '\t': case '.': case ',': case '!':
case '?': case ';': case '$': case '@': case '#':
case '%': case '^': case '(': case ')': case '[':
case ']': case '{': case '}': case '&': case '*':
continue;
default: break;
}
// If you got this far, the character is accepted, so
// copy it to the clean part of the string. Then move
// the pointer up one character.
clean[0] = original[0];
clean++;
}

// At the end you will have equal or less than the original
// length of the string. So whatever it is, copy a null
// character to signify the end of the newly cleaned string.
clean[0] = '\0';
return String;
}
[/code]
Using switch statements like this is perfectly fine, especially when the list of rejected characters could ...

WaltP commented: You have a penchant for wroting people's code for them. Please stop. We are not a coding repository. We help people write their own code. -3

Yeah, like I said, if NULL is not pointing to zero, the calloc() pointer will no longer be compatible with NULL.

I would argue, though, that since NULL is a macro, and since macro's allow for better portability in C, that it is "safe" to redefine NULL within the context of your code if you choose to let calloc() or memset() do your NULL assignment for you. Personally I think its safer to have those functions set all your structures to zero in case you forget to initialize the structure or use a complex system of nested or recursive malloc's to structures. I would assume that 0xdeadbeef helps alert someone who is debugging their code that a pointer with NULL was not assigned a value, which would be easier to identify than "attempt to access 0x00000000" errors.

Either way, I understand your point and this really boils down to preference, not portability, since as I said, its a C macro and its completely legal to redefine it within your own programs context.