char * & char []
-
What is the difference between char *ptr="babu" char ptr[]="babu" babu
-
What is the difference between char *ptr="babu" char ptr[]="babu" babu
Nothing... The 2nd declaration is more readable through the program, as it is clear that you are using an array. Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
-
What is the difference between char *ptr="babu" char ptr[]="babu" babu
-
Nothing... The 2nd declaration is more readable through the program, as it is clear that you are using an array. Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
There is a difference, check the disassembly
127: char aaa[] = "ssss";
004B423D mov eax,[string "ssss" (005fd498)]
004B4242 mov dword ptr [ebp-18h],eax
004B4245 mov cl,byte ptr [string "ssss"+4 (005fd49c)]
004B424B mov byte ptr [ebp-14h],cl
128: char *bbb = "bbb";
004B424E mov dword ptr [ebp-1Ch],offset string "bbb" (005fd46c)
129:
130: char *cc;
131:
132: cc = bbb;
004B4255 mov edx,dword ptr [ebp-1Ch] ; address of string is loaded from memory
004B4258 mov dword ptr [ebp-20h],edx
133: cc = aaa;
004B425B lea eax,[ebp-18h] ; cc just gets address
004B425E mov dword ptr [ebp-20h],eax
rrrado