i asked about not that diffrence............... in normal char pointer we can have to allocate contineous memory for storing string(implicitly).......... is it possible in the case of a class member.......................... eg: char *str; scanf("%s",str); will store the strring inside str(without allocating memory explicitly(means not using malloc))............ but is it possibe for a class private member.............. plz mension an eg!!!!!!!!!!!!
You must explicitly allocate memory for a string in any scope in c/c++. You must first allocate memory for a pointer before using. Your example will produce undefined results. Some times it may seem to work, but it is writing to memory it does not own. Jim
but in the case char pointer its always true in normal case........... what happent in the case of class variable
You must explicitly allocate memory for a cstring in any scope in c/c++. I does not matter if it is in a class/structure, global, or local pointer.