04-18-2015, 01:55 PM
(This post was last modified: 04-18-2015, 01:58 PM by gold_finger.)
I ran a test of your code in VirtualBox install of LL and I did not get the errors you are reporting.
I called the program "sample.c" and saved it to the Desktop. Here is the exact code I used:
I compiled it with this code:
Ran it with this command and got the following output:
Compiled it again with the following command to match what you did, ran program again and got the same output as above:
P.s. Is this line of output what you were expecting it to be?
I called the program "sample.c" and saved it to the Desktop. Here is the exact code I used:
Code:
#include <stdio.h>
#define STRINGSIZE 256
int main(int argc, char*argv[])
{
char town[STRINGSIZE]="Guildford";
char county[STRINGSIZE]="Surrey";
char country[STRINGSIZE]="Great Britain";
int population=66773;
float latitude=51.238599;
float longitude=-0.566257;
printf("Town name:%s population:%d\n",town,population);
printf("County:%s\n",county);
printf("Country:%s\n",country);
printf("Location latitude:%f longitude: % f\n",latitude,longitude);
printf("char=%d byte int=%d bytes float=%d bytes\n",
sizeof(char),sizeof(int),sizeof(float));
printf("memory used:%d bytes\n",
((STRINGSIZE*3) * sizeof(char)) + sizeof (int) + (2 * sizeof(float)));
return 0;
}
I compiled it with this code:
Code:
homey@homey-VirtualBox:~/Desktop$ gcc sample.c -o sample
Ran it with this command and got the following output:
Code:
homey@homey-VirtualBox:~/Desktop$ ./sample
Town name:Guildford population:66773
County:Surrey
Country:Great Britain
Location latitude:51.238598 longitude: -0.566257
char=1 byte int=4 bytes float=4 bytes
memory used:780 bytes
Compiled it again with the following command to match what you did, ran program again and got the same output as above:
Code:
homey@homey-VirtualBox:~/Desktop$ gcc -o sample sample.c -lc
homey@homey-VirtualBox:~/Desktop$ ./sample
Town name:Guildford population:66773
County:Surrey
Country:Great Britain
Location latitude:51.238598 longitude: -0.566257
char=1 byte int=4 bytes float=4 bytes
memory used:780 bytes
P.s. Is this line of output what you were expecting it to be?
Code:
char=1 byte int=4 bytes float=4 bytes
Try Linux Beginner Search Engine for answers to Linux questions.