theRandy
July 1st, 2013, 05:09 AM
Ok so im trying to run the following code to show the different sizes of data types:
#include <stdio.h>
int main() {
printf("The 'int' data type is\t\t %d bytes\n", sizeof(int));
printf("The 'unsigned int' data type is\t %d bytes\n", sizeof(unsigned));
printf("The 'short int' data type is\t %d bytes\n", sizeof(short int));
printf("The 'long int' data type is\t %d bytes\n", sizeof(long int));
printf("The 'long long int' data type is\t %d bytes\n", sizeof(long long int));
printf("The 'float' data type is\t %d bytes\n", sizeof(float));
printf("The 'char' data type is\t\t %d bytes\n", sizeof(char));
}
when i try compile it with GCC i get the error message
root@bt:~/Documents/Programming# gcc datatype_sizes.c -fno-builtin -g
datatype_sizes.c: In function ‘main’:
datatype_sizes.c:10: error: expected declaration or statement at end of input
root@bt:~/Documents/Programming#
and when i use ls -l a.out and then try to run the program using ./a.out it runs the wrong piece of code:
root@bt:~/Documents/Programming# gcc datatype_sizes.c -fno-builtin -g
datatype_sizes.c: In function ‘main’:
datatype_sizes.c:10: error: expected declaration or statement at end of input
root@bt:~/Documents/Programming# ls -l a.out
-rwxr-xr-x 1 root root 8471 2013-06-21 14:37 a.out
root@bt:~/Documents/Programming# ./a.out
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Any idea why this is happening, ive never had this problem up until now with GCC.
#include <stdio.h>
int main() {
printf("The 'int' data type is\t\t %d bytes\n", sizeof(int));
printf("The 'unsigned int' data type is\t %d bytes\n", sizeof(unsigned));
printf("The 'short int' data type is\t %d bytes\n", sizeof(short int));
printf("The 'long int' data type is\t %d bytes\n", sizeof(long int));
printf("The 'long long int' data type is\t %d bytes\n", sizeof(long long int));
printf("The 'float' data type is\t %d bytes\n", sizeof(float));
printf("The 'char' data type is\t\t %d bytes\n", sizeof(char));
}
when i try compile it with GCC i get the error message
root@bt:~/Documents/Programming# gcc datatype_sizes.c -fno-builtin -g
datatype_sizes.c: In function ‘main’:
datatype_sizes.c:10: error: expected declaration or statement at end of input
root@bt:~/Documents/Programming#
and when i use ls -l a.out and then try to run the program using ./a.out it runs the wrong piece of code:
root@bt:~/Documents/Programming# gcc datatype_sizes.c -fno-builtin -g
datatype_sizes.c: In function ‘main’:
datatype_sizes.c:10: error: expected declaration or statement at end of input
root@bt:~/Documents/Programming# ls -l a.out
-rwxr-xr-x 1 root root 8471 2013-06-21 14:37 a.out
root@bt:~/Documents/Programming# ./a.out
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Hello, world!
Any idea why this is happening, ive never had this problem up until now with GCC.