![]() |
When NULL When Not, In C....
Hello,
I am declearing the Following Variable: Code:
char *x = "C-PROGRAMMING";Except that instead of declaring the spaces as NULL, it starts to present me with hearts and lines and what not, everything except 0(NULL). This is how I am assigning the letters to Prog: Code:
for(int i = 0;i<strlen(y);i++){Thank you for your attention, Thanks Daniel |
Re: When NULL When Not, In C....
Code:
char *Prog = (char *)malloc(strlen(x));Be careful with your terminology. NULL generally refers to the value representing a NULL pointer, which may or may not actually be zero (though a zero has to act as a NULL in a pointer context). The value, 0, for a char is referred to as a nul, or as '\0', to reduce confusion. Your example code uses a lot of stuff you haven't bothered to define in our sight. Since we only read minds on every other Wednesday, that's not too effective. |
Re: When NULL When Not, In C....
Quote:
|
Re: When NULL When Not, In C....
Quote:
|
Re: When NULL When Not, In C....
Quote:
You don't need to cast result of malloc in C. Sometimes people do it to maintain compatibility between C and C++ code but then again there are very less situations when you will use malloc in C++. |
Re: When NULL When Not, In C....
Quote:
|
Re: When NULL When Not, In C....
Quote:
|
Re: When NULL When Not, In C....
Quote:
Quote:
Quote:
|
Re: When NULL When Not, In C....
Quote:
Code:
int main(){Code:
int main(){Quote:
|
Re: When NULL When Not, In C....
Basically I work on MFC and Win Platform where the code is compile time error
Code:
int main(){Thanks for clearing the doubts. |
| All times are GMT +5.5. The time now is 20:05. |