LINUX LITE 7.2 FINAL RELEASED - SEE RELEASE ANNOUNCEMENTS SECTION FOR DETAILS


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C Programming in Linux
#1
hi i am trying to learn to program in c. and is using this guide. C Programming in Linux © David Haskins 2008
now at chapter2_1.c i got in to a problem the compelling will not run and I can not see what's wrong, is there som help to get?

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;

Code:
Programming_In_Linux$ gcc -o data1 chapter2_1.c -lc
chapter2_1.c:7:2: error: invalid preprocessing directive #DEFINE
#DEFINE STRINGSIZE 256
  ^
chapter2_1.c: In function ‘main’:
chapter2_1.c:11:12: error: ‘STRINGSIZE’ undeclared (first use in this function)
  char town[STRINGSIZE]="Guildford";
            ^
chapter2_1.c:11:12: note: each undeclared identifier is reported only once for each function it appears in
chapter2_1.c:22:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
  sizeof(char),sizeof(int),sizeof(float));
  ^
chapter2_1.c:22:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
chapter2_1.c:22:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
Reply


Messages In This Thread
C Programming in Linux - by hhbuur - 04-14-2015, 11:16 AM
Re: C Programming in Linux - by gold_finger - 04-18-2015, 02:46 AM
Re: C Programming in Linux - by hhbuur - 04-18-2015, 10:29 AM
Re: C Programming in Linux - by gold_finger - 04-18-2015, 01:55 PM
Re: C Programming in Linux - by hhbuur - 04-19-2015, 12:05 PM
Re: C Programming in Linux - by gold_finger - 04-19-2015, 02:24 PM
Re: C Programming in Linux - by avj - 04-19-2015, 04:54 PM
Re: C Programming in Linux - by hhbuur - 04-21-2015, 09:27 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)