Hello, Im trying to figure out the difference between int[] and char[]
#include <iostream>
#include <stdlib.h>
int main()
{
int i[10] = {1};
char c[10] = {'1'};
cout << "&int \t" << &i << endl;
cout << "int \t " << i << endl;
cout << "int[0]\t" << i[0] << endl;
cout << endl;
cout << "&char \t" << &c << endl;
cout << "char\t " << c << endl;
cout << "char[0]\t" << c[0] << endl;
cout << endl;
system("PAUSE") ;
return 0;
}
I get this output :
&int 0x254fda8
int 0x254fda8
int[0] 1
&char 0x254fd98
char 1
char[0] 1
I belive long, float, double etc work the same way as int does in my above
example. How is char[] different for these other variables ? Any links to
related tutorials would be great aswell.
Cheers :)
#include <iostream>
#include <stdlib.h>
int main()
{
int i[10] = {1};
char c[10] = {'1'};
cout << "&int \t" << &i << endl;
cout << "int \t " << i << endl;
cout << "int[0]\t" << i[0] << endl;
cout << endl;
cout << "&char \t" << &c << endl;
cout << "char\t " << c << endl;
cout << "char[0]\t" << c[0] << endl;
cout << endl;
system("PAUSE") ;
return 0;
}
I get this output :
&int 0x254fda8
int 0x254fda8
int[0] 1
&char 0x254fd98
char 1
char[0] 1
I belive long, float, double etc work the same way as int does in my above
example. How is char[] different for these other variables ? Any links to
related tutorials would be great aswell.
Cheers :)
Comment