
354 Fundamentals of Computer Programming and IT
Total bytes = sizeof(data type) X size of array
The rules for array declaration are the same in
C and C++. The only difference is in the declaration of strings
i.e., character array.
Program Executed in C Program Executed in C++
# include <stdio.h> # include <stdio.h>
# include <conio.h> # include <conio.h>
void main() void main()
{ {
char text[3]=”xyz”; char text[3]=”xyz”;
char txt[3]=”abc”; char txt[3]=”abc”;
clrscr(); clrscr();
printf (“\n %s”,text); printf (“\n %s”,text);
printf (“%s”, text) printf (“%s”, text)
} }
OUTPUT OUTPUT
xyz_abcW__ xyzÅ
Explanation
Both the above programs are same. ...