Like Tree1Likes
  • 1 Post By Salem

syntax error at end of input

This is a discussion on syntax error at end of input within the C Programming forums, part of the General Programming Boards category; I have this file with c code and i;m getting syntax error at end of input this error..Could someone help ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    9

    syntax error at end of input

    I have this file with c code and i;m getting syntax error at end of input this error..Could someone help me??

    Code:
    #include "Types.h"
    
    
    void show_main_menu(int);
    account* create_new_owner_account(void);
    account *create_new_traveller_account(void);
    account* kratisi(void);
    account* traveller_action(int act2);
    
    
    char input[1000];
    char buffer[1500];
    
    
    
    
    
    
    void show_main_menu(int sd)
    {  
        printf("Eiste idiokthths parking (pieste 1) h' eiste taksidiotis(pieste 7) ");
         
        get_input:    //label
        printf("client> ");
        fgets(input, 100, stdin);
        
        if(strlen(input) > 2) {
            printf("La8os epilogh parakalw pieste ksana\n");    
            goto get_input;
        }
        
        switch(input[0]) {
                          case '1': {
                              printf("\n|----------------|\n");
                              printf("|------MENU------|\n");
                              printf("|----------------|\n");
                              printf("\n|---------------------|\n");
                              printf("1. Dhlwsh neou parking\n");
                              printf("|---------------------|\n");
                              printf("\n|------------------------------|\n");
                              printf("2. Provolh teleytaiwn krathsewn\n");
                              printf("|------------------------------|\n");
                               printf("----------------------\n\n");
                              printf("Grapste thn epilogh sas\n");
                              
                              get_input1:    //label
                              printf("client> ");
                              fgets(input, 100, stdin);
        
                              if(strlen(input) > 2) {
                              printf("La8os epilogh parakalw pieste ksana\n");    
                              goto get_input1;
                                                    }//if
                              
                              switch(input[0]) {
                                                case '1':
                                                     if((write(sd, create_new_owner_account(), sizeof(account)) == -1)) {//klhsh synarthshs gia neo logariasmo
                                                     perror("write");
                                                     exit(1);    
                                                     }        //if                                   
                                                  break;           
                                                  
                                                case '2':
                                                     if((write(sd, owner_action(), sizeof(account)) == -1)) {//klhsh synarthshs gia tis leitourgies tou client
                                                     perror("write");
                                                     exit(1);
                                                  }//if
                                                  break;
                                                                                                                                                                                      
    }
    break;//gia to case=idiokthths  
                          
                          
                          case '7'://gia epilogh taksidioth
                          {
                              printf("\n|----------------|\n");
                              printf("\n-----MENU-----\n");
                              printf("|----------------|\n");
                              printf("\n|-----------------------------|\n");
                              printf("3. Dhmiourgia neou logariasmou.\n");
                              printf("|-----------------------------|\n");
                              printf("\n|------------------|\n");
                              printf("4. Krathsh parking \n");
                              printf("|------------------|\n");
                              printf("\n|-----------------------------|\n");
                              printf("5. Provolh stoixeiwn logariasmou");
                              printf("|-----------------------------|\n");
                              printf("\n|------------------|\n");
                              printf("6. Kata8esh xrhmatwn. \n");
                              printf("|------------------|\n");
                              printf("----------------------\n\n");
                              printf("Grapste thn epilogh sas\n"); 
                              
                              get_input2:    //label
                              printf("client> ");
                              fgets(input, 100, stdin);
        
                              if(strlen(input) > 2) {
                              printf("La8os epilogh parakalw pieste ksana\n");    
                              goto get_input2;
        }//if
                               
                               switch(input[0]) {
                                                 case '3':       
                                                      if((write(sd , create_new_traveller_account(), sizeof(account)) == -1)) {// klhsh synarthshs pou ftiaxnei neo logariasmo taksidioti
                                                      perror("write");
                                                      exit(1);
                               }//if
                               break;
                               
                                                 case '4':
                                                      if((write(sd, kratisi(), sizeof(account)) == -1)); {//klhsh synarthshs gia krathsh
                                                                   perror("write");
                                                                   exit(1);
                                                                   }//if
                                                      break;
                                                      
                                                 case '5':
                                                      if(write(sd , traveller_account_action(SHOWT), sizeof(account)) == -1) {//klhsh synarthshs gia leitourgies taksidioti
                                                      perror("write");
                                                      exit(1);
                                                      }//if
                                                      break;
                                                      
                                                 case '6':
                                                      if(write(sd , traveller_account_action(DEPOSIT), sizeof(account)) == -1) {
                                                      perror("write");
                                                      exit(1);
                                                      }//if
                                                      break;
                                                 case '7':
                                                      exit(0);
                                                      break;
                                                   default:
                                                   printf("Wrong choice.Please enter your choice again\n");
                                                   goto get_input2;
                                                      
                                                      }//gia to case=taksidiotis
                                                      break;
                                                                                                                                                                                                     
    }//gia th main_menu
    
    
    account* create_new_owner_account(void)
    {
        account *new_owner_account; //deikths se domh typou account
        new_owner_account = (account*)malloc(sizeof(account)); //dhmiourgia, sth mnhnh, mias domhs typou account.
        new_owner_account->type=0;//orizoume oti eimaste se struct gia owner
        
        name: //label
        printf("Dwste to onoma tou parking(max 15 chars): ");
        fgets(input, 100, stdin);
    
    
        if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
            strncpy(new_owner_account->parking, input, 15); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
            new_owner_account->parking[15] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
        }//if
        else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
            printf("Prepei na dwsete ena onoma me to ligotero dyo grammata\n");
            goto name;
        }//else
    
    
        description:
        printf("Dwste perigrafh gia to parking (max 80 chars): ");
        fgets(input, 100, stdin);
    
    
        if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
            strncpy(new_owner_account->description_nametraveller, input, 80); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
            new_owner_account->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                              }//if
        else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
            printf("Prepei na dwsete mia perigrafh me to ligotero dyo grammata\n");
            goto description;
        }//else
            
        price: //label
        printf("Dwste thn timh tou parking ");
        fgets(input, 100, stdin);
        if(strlen(input) <= 1) {//an o xrhsths pathsei enter xoris na dosei kapoio noumero tou leme na ksanadosei.
            printf("Prepei na dwsete mia timh me to ligotero ena pshfio!\n");
            goto price;
        }//if
        int i;
        /* elegxoume an h eisodos tou xrhsth periexei mono noumera allios ton parapempume na ksanadosei kainourgia eisodo. */
        for(i=0; i<strlen(input)-1; i++) {
            if(isdigit(input[i]) == 0) {//einai pshfio?
                printf("La8os timh mono ari8moi!\n");
                goto price;
            }//if
        }//for
    
    
    /* an h eisodos htan egkyrh metatrepoume meso ths atoi to alfari8mitiko
         * se int kai to apo8hkeuoume sto melos balance ths domhs account. */
        
        new_owner_account->price_logariasmos = atoi(input);
        new_owner_account->positions = 10;//arxika exoume 10 eley8eres 8eseis    
        new_owner_account->all_transactions = 0; //o ari8mos ton synnallagon arxika einai 0
        int j;
        /* arxikopoioume to melos type, ths domhs transaction pou me th seira ths
         * einai melos ths domhs account, me thn sta8era UNKNOWN. To kanoume ayto
         * gia na boh8h8oume ston elegxo pou kanoume apo ton server. */
        for(j=0; j<20; j++)
            new_owner_account->pinakas[j].type = UNKNOWN;
        
        
        new_owner_account->action = CREATE_ACCOUNT;
        
    return new_owner_account;
    }//gia th create_owner
    
    
    account *create_new_traveller_account(void)
    {
                      account *new_traveller_account;
                      new_traveller_account = (account*)malloc(sizeof(account)); //dhmiourgia, sth mnhnh, mias domhs typou account.
                      new_traveller_account->type=1;//orizoume oti eimaste se traveller
                      
                      name1: //label
                      printf("Dwste to onoma tou taksidioti (max 40 chars): ");
                      fgets(input, 100, stdin);
    
    
                      if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
                      strncpy(new_traveller_account->description_nametraveller, input, 40); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
                      new_traveller_account->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                                            }//if
                      else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
                      printf("Prepei na dwsete onoma me toulaxiston dyo xarakthres\n");
                      goto name1;
                           }//else
    
    
                      balance: //label
                      printf("Dwste to arxiko ypoloipo ");
                      fgets(input, 100, stdin);
                      if(strlen(input) <= 1) {//an o xrhsths pathsei enter xoris na dosei kapoio noumero tou leme na ksanadosei.
                      printf("Prepei na dwsete ena ari8mo me to ligotero ena pshfio\n");
                      goto balance;
                                               }//if
                      int i;
        /* elegxoume an h eisodos tou xrhsth periexei mono noumera allios ton parapempume na ksanadosei kainourgia eisodo. */
                     for(i=0; i<strlen(input)-1; i++) {
                     if(isdigit(input[i]) == 0) {//einai pshfio?
                     printf("La8os timh, prepei na periexei mono ari8mous!\n");
                     goto balance;
                                                    }//if
                                                 }//for
        /* an h eisodos htan egkyrh metatrepoume meso ths atoi to alfari8mitiko
         * se int kai to apo8hkeuoume sto melos balance ths domhs account. */
                     new_traveller_account->price_logariasmos = atoi(input);
                     new_traveller_account->all_transactions = 0; //o ari8mos ton synnallagon arxika einai 0
                     int j;
        /* arxikopoioume to melos type, ths domhs transaction pou me th seira ths
         * einai melos ths domhs account, me thn sta8era UNKNOWN. To kanoume ayto
         * gia na boh8h8oume ston elegxo pou kanoume apo ton server. */
                     for(j=0; j<4; j++)
                     new_traveller_account->pinakas[j].type = UNKNOWN;
    
    
                     new_traveller_account->action = CREATE_ACCOUNT; //h energeia edo einai dhmiourgia logariasmou
    
    
        /* epistrefoume ena deikth typou account pou deixnei ston neodhmiourgh8enta
         * logariasmo me ta stoixeia pou edose o xrhshs. */
    
    
    return new_traveller_account;
    }//create_new_traveller
    
    
    account* owner_action(int act)
    {
                   
                   account *owner_action; //deikths se domh typou account
                   owner_action = (account*)malloc(sizeof(account)); //dhmiourgia, sth mnhnh, mias domhs typou account.
                              
                   name3: //label
                   printf("\n Dwste onoma parking pou sas endiaferei.\n"); 
                   fgets(input, 100, stdin);
    
    
                   if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
                   strncpy(owner_action->parking, input, 15); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
                   owner_action->parking[15] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                                         }//if
                   else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
                   printf("Prepei na dwsete ena onoma me to ligotero dyo grammata\n");
                   goto name3;
        }
           
                   //strncpy(owner_action->parking, input, 15);
    return owner_action;                                                                                                                                                                                  
    }//owner action
    
    
    account* kratisi(void)
    {
             
              account *kratisi_search;         
              kratisi_search = (account*)malloc(sizeof(account));        
              
              name4: //label
              printf("Dwste to onoma tou taksidioti (max 40 chars): ");
              fgets(input, 100, stdin);
    
    
              if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
              strncpy(kratisi_search->description_nametraveller, input, 40); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
              kratisi_search->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                                            }//if
              else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
              printf("Prepei na dwsete onoma me toulaxiston dyo xarakthres\n");
              goto name4;
                    }//else
              
              kratisi_search->action=SHOW;
    
    
    return kratisi_search;                           
    }//kratisi
    
    
    account* traveller_action(int act2)
    {
                       
        account *account_to_search; //deikths se domh typou account.
        account_to_search = (account*)malloc(sizeof(account));
        account_to_search->action = act2;
              
             if(act2==SHOWT) {                         
                             name5:
                             printf("\nDwste to onoma tou taksidioti pou sas endiaferei.\n");
                             fgets(input, 100, stdin);
    
    
                             if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
                             strncpy(account_to_search->description_nametraveller, input, 40); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
                             account_to_search->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                                            }//if
                             else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
                             printf("Prepei na dwsete onoma me toulaxiston dyo xarakthres\n");
                             goto name5;
                             
                             }//else
                             strncpy(account_to_search->description_nametraveller, input, 40);
                             account_to_search->description_nametraveller[80] = '\0';
                            }
                            
             if(act2==DEPOSIT) {
                               amount: //label
                               printf("Ti poso 8elete na kata8esete: ");
                               fgets(input, 100, stdin);
    
    
                if(strlen(input) <= 1) {
                                 printf("Prepei na dwsete ari8mo me dyo toulaxiston pshfia!\n");
                                 goto amount;
                                          }
                                          
                int j;
                for(j=0; j<strlen(input)-1; j++) {
                    if(isdigit(input[j]) == 0) {
                        printf("La8os, to poso prepei na periexei mono ari8mous!\n");
                        goto amount;
                    }
                }
                /* efoson o xrhsths edose egkuro poso(dhladh mono ari8mous) to metatrepoume
                 * se int meso ths atoi kai to apo8hkeuoume sto melos amount tou account. */
                account_to_search->price_logariasmos = atoi(input);
                                                                                 
                               }
    
    
    return account_to_search;
    
    
    }//gia traveller action
         
        
    int main(void)
    {
        int socket_desc, len, t; //metablhtes gia ta sockets.
        struct sockaddr_un remote; //domh gia th die8unsh tou socket tou server.
    
    
        if((socket_desc = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { //dhmiourgia tou socket tou client.
            perror("socket");
            exit(1);
        }
    
    
        printf("Trying to connect...\n");
        remote.sun_family = AF_UNIX;
        strcpy(remote.sun_path, SOCK_PATH);
        len = strlen(remote.sun_path) + sizeof(remote.sun_family);
        /* klhsh systhmatos gia th syndesh tou client kai tou server meso socket. */
        if(connect(socket_desc, (struct sockaddr *)&remote, len) == -1) {
            perror("connect");
            exit(1);
        }
        printf("Connected.\n");
    
    
        while(!feof(stdin)) {
    
    
            /* kaloume thn synarthshshow_main_menu() me orisma to descriptor tou socket pou dhmiourghsame. */
            show_main_menu(socket_desc);
    
    
            /* diabazei kai apo8hkeuei ston pinaka buffer to mhnyma pou stelnei o server.
             * an to mhkos tou string mhnymatos pou esteile o server einai 8etiko to ektyponoume. */
            if((t = read(socket_desc, buffer, 300)) > 0) {
                buffer[t] = '\0';
                printf("server>\n%s", buffer);
                exit(0);
            }
            else {
                if(t < 0) perror("read"); //o server esteile mhnyma me arnhtiko mhkos == error.
                else printf("Server closed connection\n"); //o server esteile keno mhnyma.
                exit(1);
            }
        }
        close(socket_desc); //kleinoume th sundesh client kai server kleinontas to socket.
    
    
        return 0;
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    Well it's mostly because your indentation is so lousy that you have this problem in the first place.
    SourceForge.net: Indentation - cpwiki

    Always (and I mean ALWAYS) type the closing brace immediately after typing the open brace.
    Then move the cursor back one character and then type what it is you wanted to do.

    Here is what your code looks like, following indentation rules.
    Code:
    #include "Types.h"
    
    void show_main_menu(int);
    account* create_new_owner_account(void);
    account *create_new_traveller_account(void);
    account* kratisi(void);
    account* traveller_action(int act2);
    
    char input[1000];
    char buffer[1500];
    
    void show_main_menu(int sd)
    {  
        printf("Eiste idiokthths parking (pieste 1) h' eiste taksidiotis(pieste 7) ");
        
        get_input:    //label
        printf("client> ");
        fgets(input, 100, stdin);
        
        if(strlen(input) > 2) {
            printf("La8os epilogh parakalw pieste ksana\n");    
            goto get_input;
        }
        
        switch(input[0]) {
        case '1': {
                printf("\n|----------------|\n");
                printf("|------MENU------|\n");
                printf("|----------------|\n");
                printf("\n|---------------------|\n");
                printf("1. Dhlwsh neou parking\n");
                printf("|---------------------|\n");
                printf("\n|------------------------------|\n");
                printf("2. Provolh teleytaiwn krathsewn\n");
                printf("|------------------------------|\n");
                printf("----------------------\n\n");
                printf("Grapste thn epilogh sas\n");
                
                get_input1:    //label
                printf("client> ");
                fgets(input, 100, stdin);
                
                if(strlen(input) > 2) {
                    printf("La8os epilogh parakalw pieste ksana\n");    
                    goto get_input1;
                }//if
                
                switch(input[0]) {
                case '1':
                    if((write(sd, create_new_owner_account(), sizeof(account)) == -1)) {//klhsh synarthshs gia neo logariasmo
                        perror("write");
                        exit(1);    
                    }        //if                                   
                    break;           
                    
                case '2':
                    if((write(sd, owner_action(), sizeof(account)) == -1)) {//klhsh synarthshs gia tis leitourgies tou client
                        perror("write");
                        exit(1);
                    }//if
                    break;
                    
                }
                break;//gia to case=idiokthths  
                
            case '7'://gia epilogh taksidioth
                {
                    printf("\n|----------------|\n");
                    printf("\n-----MENU-----\n");
                    printf("|----------------|\n");
                    printf("\n|-----------------------------|\n");
                    printf("3. Dhmiourgia neou logariasmou.\n");
                    printf("|-----------------------------|\n");
                    printf("\n|------------------|\n");
                    printf("4. Krathsh parking \n");
                    printf("|------------------|\n");
                    printf("\n|-----------------------------|\n");
                    printf("5. Provolh stoixeiwn logariasmou");
                    printf("|-----------------------------|\n");
                    printf("\n|------------------|\n");
                    printf("6. Kata8esh xrhmatwn. \n");
                    printf("|------------------|\n");
                    printf("----------------------\n\n");
                    printf("Grapste thn epilogh sas\n"); 
                    
                    get_input2:    //label
                    printf("client> ");
                    fgets(input, 100, stdin);
                    
                    if(strlen(input) > 2) {
                        printf("La8os epilogh parakalw pieste ksana\n");    
                        goto get_input2;
                    }//if
                    
                    switch(input[0]) {
                    case '3':       
                        if((write(sd , create_new_traveller_account(), sizeof(account)) == -1)) {// klhsh synarthshs pou ftiaxnei neo logariasmo taksidioti
                            perror("write");
                            exit(1);
                        }//if
                        break;
                        
                    case '4':
                        if((write(sd, kratisi(), sizeof(account)) == -1)); {//klhsh synarthshs gia krathsh
                            perror("write");
                            exit(1);
                        }//if
                        break;
                        
                    case '5':
                        if(write(sd , traveller_account_action(SHOWT), sizeof(account)) == -1) {//klhsh synarthshs gia leitourgies taksidioti
                            perror("write");
                            exit(1);
                        }//if
                        break;
                        
                    case '6':
                        if(write(sd , traveller_account_action(DEPOSIT), sizeof(account)) == -1) {
                            perror("write");
                            exit(1);
                        }//if
                        break;
                    case '7':
                        exit(0);
                        break;
                    default:
                        printf("Wrong choice.Please enter your choice again\n");
                        goto get_input2;
                        
                    }//gia to case=taksidiotis
                    break;
                    
                }//gia th main_menu
    
    
                account* create_new_owner_account(void)
                {
                    account *new_owner_account; //deikths se domh typou account
                    new_owner_account = (account*)malloc(sizeof(account)); //dhmiourgia, sth mnhnh, mias domhs typou account.
                    new_owner_account->type=0;//orizoume oti eimaste se struct gia owner
                    
    name: //label
                    printf("Dwste to onoma tou parking(max 15 chars): ");
                    fgets(input, 100, stdin);
    
                    if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
                        strncpy(new_owner_account->parking, input, 15); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
                        new_owner_account->parking[15] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                    }//if
                    else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
                        printf("Prepei na dwsete ena onoma me to ligotero dyo grammata\n");
                        goto name;
                    }//else
    
    description:
                    printf("Dwste perigrafh gia to parking (max 80 chars): ");
                    fgets(input, 100, stdin);
    
                    if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
                        strncpy(new_owner_account->description_nametraveller, input, 80); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
                        new_owner_account->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                    }//if
                    else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
                        printf("Prepei na dwsete mia perigrafh me to ligotero dyo grammata\n");
                        goto description;
                    }//else
                    
    price: //label
                    printf("Dwste thn timh tou parking ");
                    fgets(input, 100, stdin);
                    if(strlen(input) <= 1) {//an o xrhsths pathsei enter xoris na dosei kapoio noumero tou leme na ksanadosei.
                        printf("Prepei na dwsete mia timh me to ligotero ena pshfio!\n");
                        goto price;
                    }//if
                    int i;
                    /* elegxoume an h eisodos tou xrhsth periexei mono noumera allios ton parapempume na ksanadosei kainourgia eisodo. */
                    for(i=0; i<strlen(input)-1; i++) {
                        if(isdigit(input[i]) == 0) {//einai pshfio?
                            printf("La8os timh mono ari8moi!\n");
                            goto price;
                        }//if
                    }//for
    
                    /* an h eisodos htan egkyrh metatrepoume meso ths atoi to alfari8mitiko
        * se int kai to apo8hkeuoume sto melos balance ths domhs account. */
                    new_owner_account->price_logariasmos = atoi(input);
                    new_owner_account->positions = 10;//arxika exoume 10 eley8eres 8eseis    
                    new_owner_account->all_transactions = 0; //o ari8mos ton synnallagon arxika einai 0
                    int j;
                    /* arxikopoioume to melos type, ths domhs transaction pou me th seira ths
        * einai melos ths domhs account, me thn sta8era UNKNOWN. To kanoume ayto
        * gia na boh8h8oume ston elegxo pou kanoume apo ton server. */
                    for(j=0; j<20; j++)
                    new_owner_account->pinakas[j].type = UNKNOWN;
                    
                    new_owner_account->action = CREATE_ACCOUNT;
                    return new_owner_account;
                }//gia th create_owner
    
                account *create_new_traveller_account(void)
                {
                    account *new_traveller_account;
                    new_traveller_account = (account*)malloc(sizeof(account)); //dhmiourgia, sth mnhnh, mias domhs typou account.
                    new_traveller_account->type=1;//orizoume oti eimaste se traveller
                    
    name1: //label
                    printf("Dwste to onoma tou taksidioti (max 40 chars): ");
                    fgets(input, 100, stdin);
    
                    if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
                        strncpy(new_traveller_account->description_nametraveller, input, 40); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
                        new_traveller_account->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                    }//if
                    else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
                        printf("Prepei na dwsete onoma me toulaxiston dyo xarakthres\n");
                        goto name1;
                    }//else
    
    balance: //label
                    printf("Dwste to arxiko ypoloipo ");
                    fgets(input, 100, stdin);
                    if(strlen(input) <= 1) {//an o xrhsths pathsei enter xoris na dosei kapoio noumero tou leme na ksanadosei.
                        printf("Prepei na dwsete ena ari8mo me to ligotero ena pshfio\n");
                        goto balance;
                    }//if
                    int i;
                    /* elegxoume an h eisodos tou xrhsth periexei mono noumera allios ton parapempume na ksanadosei kainourgia eisodo. */
                    for(i=0; i<strlen(input)-1; i++) {
                        if(isdigit(input[i]) == 0) {//einai pshfio?
                            printf("La8os timh, prepei na periexei mono ari8mous!\n");
                            goto balance;
                        }//if
                    }//for
                    /* an h eisodos htan egkyrh metatrepoume meso ths atoi to alfari8mitiko
        * se int kai to apo8hkeuoume sto melos balance ths domhs account. */
                    new_traveller_account->price_logariasmos = atoi(input);
                    new_traveller_account->all_transactions = 0; //o ari8mos ton synnallagon arxika einai 0
                    int j;
                    /* arxikopoioume to melos type, ths domhs transaction pou me th seira ths
        * einai melos ths domhs account, me thn sta8era UNKNOWN. To kanoume ayto
        * gia na boh8h8oume ston elegxo pou kanoume apo ton server. */
                    for(j=0; j<4; j++)
                    new_traveller_account->pinakas[j].type = UNKNOWN;
                    new_traveller_account->action = CREATE_ACCOUNT; //h energeia edo einai dhmiourgia logariasmou
    
                    /* epistrefoume ena deikth typou account pou deixnei ston neodhmiourgh8enta
        * logariasmo me ta stoixeia pou edose o xrhshs. */
                    return new_traveller_account;
                }//create_new_traveller
    
                account* owner_action(int act)
                {
                    account *owner_action; //deikths se domh typou account
                    owner_action = (account*)malloc(sizeof(account)); //dhmiourgia, sth mnhnh, mias domhs typou account.
                    
    name3: //label
                    printf("\n Dwste onoma parking pou sas endiaferei.\n"); 
                    fgets(input, 100, stdin);
    
                    if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
                        strncpy(owner_action->parking, input, 15); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
                        owner_action->parking[15] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                    }//if
                    else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
                        printf("Prepei na dwsete ena onoma me to ligotero dyo grammata\n");
                        goto name3;
                    }
                    
                    //strncpy(owner_action->parking, input, 15);
                    return owner_action;                                                                                                                                                                                  
                }//owner action
    
                account* kratisi(void)
                {
                    account *kratisi_search;         
                    kratisi_search = (account*)malloc(sizeof(account));        
                    
    name4: //label
                    printf("Dwste to onoma tou taksidioti (max 40 chars): ");
                    fgets(input, 100, stdin);
    
                    if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
                        strncpy(kratisi_search->description_nametraveller, input, 40); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
                        kratisi_search->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                    }//if
                    else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
                        printf("Prepei na dwsete onoma me toulaxiston dyo xarakthres\n");
                        goto name4;
                    }//else
                    
                    kratisi_search->action=SHOW;
                    return kratisi_search;                           
                }//kratisi
    
                account* traveller_action(int act2)
                {
                    account *account_to_search; //deikths se domh typou account.
                    account_to_search = (account*)malloc(sizeof(account));
                    account_to_search->action = act2;
                    
                    if(act2==SHOWT) {                         
    name5:
                        printf("\nDwste to onoma tou taksidioti pou sas endiaferei.\n");
                        fgets(input, 100, stdin);
    
                        if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
                            strncpy(account_to_search->description_nametraveller, input, 40); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
                            account_to_search->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                        }//if
                        else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
                            printf("Prepei na dwsete onoma me toulaxiston dyo xarakthres\n");
                            goto name5;
                            
                        }//else
                        strncpy(account_to_search->description_nametraveller, input, 40);
                        account_to_search->description_nametraveller[80] = '\0';
                    }
                    
                    if(act2==DEPOSIT) {
    amount: //label
                        printf("Ti poso 8elete na kata8esete: ");
                        fgets(input, 100, stdin);
    
                        if(strlen(input) <= 1) {
                            printf("Prepei na dwsete ari8mo me dyo toulaxiston pshfia!\n");
                            goto amount;
                        }
                        
                        int j;
                        for(j=0; j<strlen(input)-1; j++) {
                            if(isdigit(input[j]) == 0) {
                                printf("La8os, to poso prepei na periexei mono ari8mous!\n");
                                goto amount;
                            }
                        }
                        /* efoson o xrhsths edose egkuro poso(dhladh mono ari8mous) to metatrepoume
                * se int meso ths atoi kai to apo8hkeuoume sto melos amount tou account. */
                        account_to_search->price_logariasmos = atoi(input);
                        
                    }
                    return account_to_search;
                }//gia traveller action
                
                int main(void)
                {
                    int socket_desc, len, t; //metablhtes gia ta sockets.
                    struct sockaddr_un remote; //domh gia th die8unsh tou socket tou server.
    
    
                    if((socket_desc = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { //dhmiourgia tou socket tou client.
                        perror("socket");
                        exit(1);
                    }
    
                    printf("Trying to connect...\n");
                    remote.sun_family = AF_UNIX;
                    strcpy(remote.sun_path, SOCK_PATH);
                    len = strlen(remote.sun_path) + sizeof(remote.sun_family);
                    /* klhsh systhmatos gia th syndesh tou client kai tou server meso socket. */
                    if(connect(socket_desc, (struct sockaddr *)&remote, len) == -1) {
                        perror("connect");
                        exit(1);
                    }
                    printf("Connected.\n");
    
                    while(!feof(stdin)) {
                        /* kaloume thn synarthshshow_main_menu() me orisma to descriptor tou socket pou dhmiourghsame. */
                        show_main_menu(socket_desc);
    
                        /* diabazei kai apo8hkeuei ston pinaka buffer to mhnyma pou stelnei o server.
            * an to mhkos tou string mhnymatos pou esteile o server einai 8etiko to ektyponoume. */
                        if((t = read(socket_desc, buffer, 300)) > 0) {
                            buffer[t] = '\0';
                            printf("server>\n%s", buffer);
                            exit(0);
                        }
                        else {
                            if(t < 0) perror("read"); //o server esteile mhnyma me arnhtiko mhkos == error.
                            else printf("Server closed connection\n"); //o server esteile keno mhnyma.
                            exit(1);
                        }
                    }
                    close(socket_desc); //kleinoume th sundesh client kai server kleinontas to socket.
    
                    return 0;
                }
    Look around line 135.
    show_main_menu is missing several closing braces.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    9
    tnx for your answer but after i posted this code i've found the braces missing and some other errors but still ths same error..If you don't mind plz check this code..
    Code:
    #include "types.h"
    
    
    void show_main_menu(int);
    account* create_new_owner_account(void);
    account* create_new_traveller_account(void);
    account* kratisi(void);
    account* traveller_action(int);
    
    
    char input[100];
    char buffer[1500];
    
    
    
    
    
    
    void show_main_menu(int sd)
    {  
        printf("Eiste idiokthths parking (pieste 1) h' eiste taksidiotis(pieste 7) ");
         
        get_input:	//label
    	printf("client> ");
    	fgets(input, 100, stdin);
    	
    	if(strlen(input) > 2) {
    		printf("La8os epilogh parakalw pieste ksana\n");	
            goto get_input;
    	}//if
    	
    	switch(input[0]) {
                          case '1': {
                              printf("\n|----------------|\n");
                              printf("|------MENU------|\n");
                              printf("|----------------|\n");
                              printf("\n|---------------------|\n");
                              printf("1. Dhlwsh neou parking\n");
                              printf("|---------------------|\n");
                              printf("\n|------------------------------|\n");
                              printf("2. Provolh teleytaiwn krathsewn\n");
                              printf("|------------------------------|\n");
                         	  printf("----------------------\n\n");
    	                      printf("Grapste thn epilogh sas\n");
    	                      
    	                      get_input1:	//label
    	                      printf("client> ");
    	                      fgets(input, 100, stdin);
    	
    	                      if(strlen(input) > 2) {
    		                  printf("La8os epilogh parakalw pieste ksana\n");	
                              goto get_input1;
                                                    }//if
                              
                              switch(input[0]) {
                                                case '1':
                                                     if((write(sd, create_new_owner_account(), sizeof(account)) == -1)) {//klhsh synarthshs gia neo logariasmo
    				                                 perror("write");
    				                                 exit(1);	
                                                     }		//if                                   
                                                  break;           
                                                  
                                                case '2':
                                                     if((write(sd, owner_action(), sizeof(account)) == -1)) {//klhsh synarthshs gia tis leitourgies tou client
    				                                 perror("write");
    				                                 exit(1);
    			                                  }//if
    			                                  break;
                                                                                                                                                                                      
    }
    break;//gia to case=idiokthths  
                          
                          
                          case '7'://gia epilogh taksidioth
                          {
                              printf("\n|----------------|\n");
                              printf("\n-----MENU-----\n");
                              printf("|----------------|\n");
                              printf("\n|-----------------------------|\n");
                              printf("3. Dhmiourgia neou logariasmou.\n");
                              printf("|-----------------------------|\n");
                              printf("\n|------------------|\n");
                              printf("4. Krathsh parking \n");
                              printf("|------------------|\n");
                              printf("\n|-----------------------------|\n");
                              printf("5. Provolh stoixeiwn logariasmou");
                              printf("|-----------------------------|\n");
                              printf("\n|------------------|\n");
                              printf("6. Kata8esh xrhmatwn. \n");
                              printf("|------------------|\n");
                              printf("----------------------\n\n");
    	                      printf("Grapste thn epilogh sas\n"); 
                              
                              get_input2:	//label
    	                      printf("client> ");
    	                      fgets(input, 100, stdin);
    	
    	                      if(strlen(input) > 2) {
    		                  printf("La8os epilogh parakalw pieste ksana\n");	
                              goto get_input2;
    	                                            }//if
                               
                               switch(input[0]) {
                                                 case '3':       
                                                      if((write(sd , create_new_traveller_account(), sizeof(account)) == -1)) {// klhsh synarthshs pou ftiaxnei neo logariasmo taksidioti
                                                      perror("write");
                                                      exit(1);
                                                                                                                              }//if
                               break;
                               
                                                 case '4':
                                                      if((write(sd, kratisi(), sizeof(account)) == -1)); {//klhsh synarthshs gia krathsh
                                                                   perror("write");
                                                                   exit(1);
                                                                   }//if
                                                      break;
                                                      
                                                 case '5':
                                                      if(write(sd , traveller_account_action(SHOWT), sizeof(account)) == -1) {//klhsh synarthshs gia leitourgies taksidioti
                                                      perror("write");
                                                      exit(1);
                                                      }//if
                                                      break;
                                                      
                                                 case '6':
                                                      if(write(sd , traveller_account_action(DEPOSIT), sizeof(account)) == -1) {
                                                      perror("write");
                                                      exit(1);
                                                      }//if
                                                      break;
                                                 case '7':
                                                      exit(0);
    			                                      break;
    		                                       default:
    			                                   printf("Wrong choice.Please enter your choice again\n");
    			                                   goto get_input2;
                                                      
                                                      }//gia to case=taksidiotis
                                                      break;
                                                                                                                                                                                                     
    }//gia th main_menu
    
    
    account *create_new_owner_account(void)
    {
    	account *new_owner_account; //deikths se domh typou account
    	new_owner_account = (account*)malloc(sizeof(account)); //dhmiourgia, sth mnhnh, mias domhs typou account.
        new_owner_account->type=0;//orizoume oti eimaste se struct gia owner
        
        name: //label
    	printf("Dwste to onoma tou parking(max 15 chars): ");
    	fgets(input, 100, stdin);
    
    
    	if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
    		strncpy(new_owner_account->parking, input, 15); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
    		new_owner_account->parking[15] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
        }//if
        else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
    		printf("Prepei na dwsete ena onoma me to ligotero dyo grammata\n");
    		goto name;
    	}//else
    
    
        description:
        printf("Dwste perigrafh gia to parking (max 80 chars): ");
    	fgets(input, 100, stdin);
    
    
    	if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
    		strncpy(new_owner_account->description_nametraveller, input, 80); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
    		new_owner_account->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                              }//if
        else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
    		printf("Prepei na dwsete mia perigrafh me to ligotero dyo grammata\n");
    		goto description;
    	}//else
    		
    	price: //label
    	printf("Dwste thn timh tou parking ");
    	fgets(input, 100, stdin);
    	if(strlen(input) <= 1) {//an o xrhsths pathsei enter xoris na dosei kapoio noumero tou leme na ksanadosei.
    		printf("Prepei na dwsete mia timh me to ligotero ena pshfio!\n");
    		goto price;
    	}//if
    	int i;
    	/* elegxoume an h eisodos tou xrhsth periexei mono noumera allios ton parapempume na ksanadosei kainourgia eisodo. */
    	for(i=0; i<strlen(input)-1; i++) {
    		if(isdigit(input[i]) == 0) {//einai pshfio?
    			printf("La8os timh mono ari8moi!\n");
    			goto price;
    		}//if
    	}//for
    
    
    /* an h eisodos htan egkyrh metatrepoume meso ths atoi to alfari8mitiko
    	 * se int kai to apo8hkeuoume sto melos balance ths domhs account. */
    	
        new_owner_account->price_logariasmos = atoi(input);
    	new_owner_account->positions = 10;//arxika exoume 10 eley8eres 8eseis    
        new_owner_account->all_transactions = 0; //o ari8mos ton synnallagon arxika einai 0
    	int j;
    	/* arxikopoioume to melos type, ths domhs transaction pou me th seira ths
    	 * einai melos ths domhs account, me thn sta8era UNKNOWN. To kanoume ayto
    	 * gia na boh8h8oume ston elegxo pou kanoume apo ton server. */
    	for(j=0; j<20; j++)
    		new_owner_account->pinakas[j].type = UNKNOWN;
        
        
        new_owner_account->action = CREATE_ACCOUNT;
        
    return new_owner_account;
    }//gia th create_owner
    
    
    account *create_new_traveller_account(void)
    {
                      account *new_traveller_account;
                      new_traveller_account = (account*)malloc(sizeof(account)); //dhmiourgia, sth mnhnh, mias domhs typou account.
                      new_traveller_account->type=1;//orizoume oti eimaste se traveller
                      
                      name1: //label
                      printf("Dwste to onoma tou taksidioti (max 40 chars): ");
                      fgets(input, 100, stdin);
    
    
    	              if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
    		          strncpy(new_traveller_account->description_nametraveller, input, 40); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
        		      new_traveller_account->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                                            }//if
                      else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
    		          printf("Prepei na dwsete onoma me toulaxiston dyo xarakthres\n");
    		          goto name1;
    	                   }//else
    
    
                      balance: //label
                      printf("Dwste to arxiko ypoloipo ");
    	              fgets(input, 100, stdin);
    	              if(strlen(input) <= 1) {//an o xrhsths pathsei enter xoris na dosei kapoio noumero tou leme na ksanadosei.
    		          printf("Prepei na dwsete ena ari8mo me to ligotero ena pshfio\n");
    		          goto balance;
    	                                       }//if
                      int i;
    	/* elegxoume an h eisodos tou xrhsth periexei mono noumera allios ton parapempume na ksanadosei kainourgia eisodo. */
    	             for(i=0; i<strlen(input)-1; i++) {
    		         if(isdigit(input[i]) == 0) {//einai pshfio?
    			     printf("La8os timh, prepei na periexei mono ari8mous!\n");
    			     goto balance;
    	                                        	}//if
    	                                         }//for
    	/* an h eisodos htan egkyrh metatrepoume meso ths atoi to alfari8mitiko
    	 * se int kai to apo8hkeuoume sto melos balance ths domhs account. */
                     new_traveller_account->price_logariasmos = atoi(input);
    	             new_traveller_account->all_transactions = 0; //o ari8mos ton synnallagon arxika einai 0
    	             int j;
    	/* arxikopoioume to melos type, ths domhs transaction pou me th seira ths
    	 * einai melos ths domhs account, me thn sta8era UNKNOWN. To kanoume ayto
    	 * gia na boh8h8oume ston elegxo pou kanoume apo ton server. */
    	             for(j=0; j<4; j++)
    		         new_traveller_account->pinakas[j].type = UNKNOWN;
    
    
    	             new_traveller_account->action = CREATE_ACCOUNT; //h energeia edo einai dhmiourgia logariasmou
    
    
    	/* epistrefoume ena deikth typou account pou deixnei ston neodhmiourgh8enta
    	 * logariasmo me ta stoixeia pou edose o xrhshs. */
    
    
    return new_traveller_account;
    }//create_new_traveller
    
    
    account* owner_action(int act)
    {
                   
                   account *owner_action; //deikths se domh typou account
    	           owner_action = (account*)malloc(sizeof(account)); //dhmiourgia, sth mnhnh, mias domhs typou account.
                              
                   name3: //label
    	           printf("\n Dwste onoma parking pou sas endiaferei.\n"); 
    	           fgets(input, 100, stdin);
    
    
    	           if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
    	           strncpy(owner_action->parking, input, 15); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
    		       owner_action->parking[15] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                                         }//if
                   else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
    		       printf("Prepei na dwsete ena onoma me to ligotero dyo grammata\n");
    		       goto name3;
    	}
           
                   //strncpy(owner_action->parking, input, 15);
    return owner_action;                                                                                                                                                                                  
    }//owner action
    
    
    account* kratisi(void)
    {
             
              account *kratisi_search;         
              kratisi_search = (account*)malloc(sizeof(account));        
              
              name4: //label
              printf("Dwste to onoma tou taksidioti (max 40 chars): ");
              fgets(input, 100, stdin);
    
    
              if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
              strncpy(kratisi_search->description_nametraveller, input, 40); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
              kratisi_search->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                                            }//if
              else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
              printf("Prepei na dwsete onoma me toulaxiston dyo xarakthres\n");
              goto name4;
    	            }//else
              
              kratisi_search->action=SHOW;
    
    
    return kratisi_search;                           
    }//kratisi
    
    
    account* traveller_action(int act2)
    {
                       
    	account *account_to_search; //deikths se domh typou account.
    	account_to_search = (account*)malloc(sizeof(account));
    	account_to_search->action = act2;
              
             if(act2==SHOWT) {                         
                             name5:
                             printf("\nDwste to onoma tou taksidioti pou sas endiaferei.\n");
                             fgets(input, 100, stdin);
    
    
                             if(strlen(input) > 2) {//an o xrhsths edose onoma megalutero apo 2 grammata.
                             strncpy(account_to_search->description_nametraveller, input, 40); //antigrafoume thn eisodo tou xrhsth sto melos name ths domhs account.
                             account_to_search->description_nametraveller[80] = '\0'; //pros8etoume ton eidiko xarakthra pou shmainei to telos enos string.
                                            }//if
                             else {//o xrhsths edose onoma me ena mono gramma opote tou leme na ksanadosei neo onoma.
                             printf("Prepei na dwsete onoma me toulaxiston dyo xarakthres\n");
                             goto name5;
                             
    	                     }//else
    	                     strncpy(account_to_search->description_nametraveller, input, 40);
    	                     account_to_search->description_nametraveller[80] = '\0';
                            }//if
                            
             if(act2==DEPOSIT) {
                               amount: //label
    			               printf("Ti poso 8elete na kata8esete: ");
    			               fgets(input, 100, stdin);
    
    
    			if(strlen(input) <= 1) {
    				             printf("Prepei na dwsete ari8mo me dyo toulaxiston pshfia!\n");
    				             goto amount;
    		                          	}//if
    		                          	
    			int j;
    			for(j=0; j<strlen(input)-1; j++) {
    				if(isdigit(input[j]) == 0) {
    					printf("La8os, to poso prepei na periexei mono ari8mous!\n");
    					goto amount;
    				}//if
    			}//for
    			/* efoson o xrhsths edose egkuro poso(dhladh mono ari8mous) to metatrepoume
    			 * se int meso ths atoi kai to apo8hkeuoume sto melos amount tou account. */
    			account_to_search->price_logariasmos = atoi(input);
                                                                                 
                               }//if
    
    
    return account_to_search;
    
    
    }//gia traveller action
         
    	
    int main(void)
    {
    	int socket_desc, len, t; //metablhtes gia ta sockets.
    	struct sockaddr_un remote; //domh gia th die8unsh tou socket tou server.
    
    
    	if((socket_desc = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { //dhmiourgia tou socket tou client.
    		perror("socket");
    		exit(1);
    	}
    
    
    	printf("Trying to connect...\n");
    	remote.sun_family = AF_UNIX;
    	strcpy(remote.sun_path, SOCK_PATH);
    	len = strlen(remote.sun_path) + sizeof(remote.sun_family);
    	/* klhsh systhmatos gia th syndesh tou client kai tou server meso socket. */
    	if(connect(socket_desc, (struct sockaddr *)&remote, len) == -1) {
    		perror("connect");
    		exit(1);
    	}
    	printf("Connected.\n");
    
    
    	while(!feof(stdin)) {
    
    
    		/* kaloume thn synarthshshow_main_menu() me orisma to descriptor tou socket pou dhmiourghsame. */
    		show_main_menu(socket_desc);
    
    
    		/* diabazei kai apo8hkeuei ston pinaka buffer to mhnyma pou stelnei o server.
    		 * an to mhkos tou string mhnymatos pou esteile o server einai 8etiko to ektyponoume. */
    		if((t = read(socket_desc, buffer, 300)) > 0) {
    			buffer[t] = '\0';
    			printf("server>\n%s", buffer);
    			exit(0);
    		}//if
    		else {
    			if(t < 0) perror("read"); //o server esteile mhnyma me arnhtiko mhkos == error.
    			else printf("Server closed connection\n"); //o server esteile keno mhnyma.
    			exit(1);
    		}//if
    	}//else
    	close(socket_desc); //kleinoume th sundesh client kai server kleinontas to socket.
    
    
    	return 0;
    }//main

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    tnx for your answer but after i posted this code i've found the braces missing and some other errors but still ths same error..If you don't mind plz check this code..
    Several possibilities for this...

    1) You have mismatched braces in your header file.
    2) You still have a mismatch in your main file
    3) There is no newline at the end of the header file
    4) There is no newline at the end of the main file

    Test compiling it on Pelles C produced hundreds of errors... most were likely because I didn't have your types.h file to work with but quite a few were syntax errors related to missing or misplaced brackets and braces.

    Also your souce layout (aka "indenting") seriously needs improvement. I would not be surprised if that is half of your problem, with this code. Hiding braces behind statements, like this...
    Code:
    if (x == 10){
      // do stuff
    ... is a primary cause of mismatches. Rearrange your code like this...
    Code:
    if (x == 10)
      {
          // do stuff
       }
    ... and it will be a lot easier to see brace mismatches and to see code nesting from levels of indentation.

    Finally, if you are not working with a syntax highlighting IDE (source editor) that does brace matching... get one. It will be a tremendous help to you.
    Last edited by CommonTater; 11-27-2011 at 07:22 AM.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    >If you don't mind plz check this code..
    Actually - I do mind (so I'm not going to).

    I've no intention of keeping up with posting readable versions of your dog-food.

    If you can't be bothered to post readable and formatted code, then get out of programming.
    Trust me, no one will want to work with you on large projects.
    rags_to_riches likes this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. syntax error at end of input
    By djdato in forum C Programming
    Replies: 3
    Last Post: 05-22-2010, 10:10 AM
  2. Replies: 4
    Last Post: 03-07-2010, 06:51 AM
  3. syntax error at end of input
    By sauoon in forum C++ Programming
    Replies: 5
    Last Post: 12-14-2009, 02:48 AM
  4. Syntax error at end of input
    By implor in forum C Programming
    Replies: 4
    Last Post: 06-16-2009, 09:39 AM
  5. syntax error at end of input
    By cerin in forum C++ Programming
    Replies: 3
    Last Post: 03-06-2005, 12:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21