Pleaseeeeee helpppppp!!!!!1

This is a discussion on Pleaseeeeee helpppppp!!!!!1 within the C Programming forums, part of the General Programming Boards category; Hi guys i run a program: and i have an error...can sb tell me where i have the mistake? Code: ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    7

    Pleaseeeeee helpppppp!!!!!1

    Hi guys i run a program: and i have an error...can sb tell me where i have the mistake?

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    int myPassword(void){
         int p;
              printf("Please type a 6 digit password:\n");
              scanf("%d", &p);
         return p;
    }     
    
    void Init(char A[][], int B[][][], char C[][][], int nrows){
         int choice2, i, key=0;
              
              printf("Please press 1 to have a sit close to a window \n");
              printf("Please press 2 to have a sit in the corridor \n");
              printf("Please press 3 to have a sit in the middle \n");
              scanf("%d", &choice2);
              printf("Please type your name:\n");
    
    			if(choice2==1){
    				for(i=0; i<nrows; i++){
    					if(A[i][0]=='-'){
    						A[i][0]='*';
    						key=1;
    					break;
    					}
    				}
    				if(key==0){		
    					for(i=0; i<nrows; i++){
    						if(A[i][0]=='-'){
    							A[i][0]='*';
    						break;
    						}
    					}
    				}
    
    			}
    //   myPassword(); //Pairnoume ton kwdiko
    }
    
    main(){
           int nrows, nseat, choice, i, j;
           char** A;
           char*** C;
           int*** B;
              printf("How many rows do you want ? \n");
              scanf("%d", &nrows);
              nseat = (nrows*6);
              printf("The seats are %d \n\n", nseat);
              
              /* For the aeroplane seats! */
              A = (char**)malloc(nrows*sizeof(char*));
              
              for(i=0; i<nrows; i++){
                    A[i] = (char*)malloc(6*sizeof(char));
              }
              
              
              for(i=0; i<nrows; i++){
                   printf("\n");
                   for(j=0; j<6; j++){
                        printf("A[%d][%d]: %c  ", i, j, A[i][j]);
                   }
              }     
              
              /* For the passwords */
              B = (int***)malloc(nrows*sizeof(int**));
              for(i=0; i<nrows; i++){
                    B[i] = (int**)malloc(6*sizeof(int*));
                        for(j=0; j<6; j++){
                             B[i][j] = (int*)malloc(6*sizeof(int));
                        }
              }
              
              
              /* For the names */
              C = (char***)malloc(nrows*sizeof(char**));
              for(i=0; i<nrows; i++){
                   C[i] = (char**)malloc(6*sizeof(char*));
                        for(j=0; j<6; j++){
                             C[i][j] = (char*)malloc(30*sizeof(char));
                        }
              }
              printf("\n\n");
         while(1){          
              
              printf(" Please press 1 to have a reservation \n");
              printf(" Please press 2 for reservations search \n");
              printf(" Please press 3 for the aeroplane plan\n");
              printf(" Please press 4 for the passenger list \n");
              printf(" Please press 0 to exit \n");
              scanf("%d", &choice);
                        
              switch(choice){
                   case 1:
                        printf("You are in case 1\n");
                        Init(A, B, C, nrows); //reservations
                       
                        break;
                   case 2:
                        printf("You are in case 2\n");
                        break;        
                   case 3:
                        printf("You are in case 3\n");
                        break;  
                   case 4:
                        printf("You are in case 4\n");
                        break;
                       case 0:
                        printf("You are about to exit!\n");
                        exit(EXIT_SUCCESS);               
                   default:
                        printf("Please give the right number\n");
                        break;                    
              }
         } // While loop
         printf("\n");     
         system("pause");
    }
    and the out put is:

    Reservations.c:11: error: array type has incomplete element type
    Reservations.c:11: error: array type has incomplete element type
    Reservations.c:11: error: array type has incomplete element type
    Reservations.c: In function ‘main’:
    Reservations.c:97: error: type of formal parameter 1 is incomplete
    Reservations.c:97: error: type of formal parameter 2 is incomplete
    Reservations.c:97: error: type of formal parameter 3 is incomplete

    Can sb help me please...

  2. #2
    Registered User
    Join Date
    Nov 2009
    Location
    Italy
    Posts
    65
    I'm not going to read your code, anyway i found that Init's function parameters are incomplete, in fact you can't declare char A[][], int B[][][], char C[][][], while you can declare those arrays as pointers like char** A, int*** B, char*** C

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    In place of:
    Code:
    void Init(char A[][], int B[][][], char C[][][], int nrows)
    Use:
    Code:
    void Init(char **A, int ***B, char ***C, int nrows)
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Apr 2010
    Posts
    7
    Correct!!! Both of you...thanks...Does any one know where i can find some stuff to read about pointers, or sth?

  5. #5
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by thunderzone View Post
    Correct!!! Both of you...thanks...Does any one know where i can find some stuff to read about pointers, or sth?
    Start with the FAQ

    Cprogramming.com FAQ > A tutorial on pointers
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  6. #6
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,806
    From the forum guidlines:
    Tips for Efficient and Successful Posting

    1. Don't use all caps.

    2. Use descriptive subject lines. Do not put URGENT!, or NEED HELP NOW, etc. in your title; it will not make people look at it any faster. Doing this makes many old time helpers on this board not look at the post at all.
    "Pleaseeeeee helpppppp!!!!!1" does not exactly fit the definition of a good post title.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

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