Reading in data from Text file

This is a discussion on Reading in data from Text file within the C Programming forums, part of the General Programming Boards category; Originally Posted by matsp Code: char pos[2][16]; char place[11][11]; int point[2]; These variables are local to the function and uninitialized ...

  1. #211
    Registered User
    Join Date
    Mar 2008
    Posts
    147
    Quote Originally Posted by matsp View Post
    Code:
       char pos[2][16];
       char place[11][11];
       int point[2];
    These variables are local to the function and uninitialized - I'm pretty sure you want them to be passed into the function.

    --
    Mats

    ok sooooooooo somthing like this
    Code:
       ****(char pos[2][16], char place[11][11],int point[2])
    i cant use void no more soooo wat i use and i dont think i need noting to return
    Last edited by fortune2k; 04-06-2008 at 07:53 AM.

  2. #212
    Registered User
    Join Date
    Mar 2008
    Posts
    147
    ive been playing around with all sorts of ways but still i get nothing

  3. #213
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by fortune2k View Post
    ive been playing around with all sorts of ways but still i get nothing
    Post what you have tried, and explain what "nothing" means.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #214
    Registered User
    Join Date
    Apr 2008
    Posts
    1
    hello i have the same assigment and have similar coding to you.. but just my displaying of the charts that dont look very nice..

  5. #215
    Registered User
    Join Date
    Mar 2008
    Posts
    147
    Quote Originally Posted by matsp View Post
    Post what you have tried, and explain what "nothing" means.

    --
    Mats

    Code:
    char 2points( char place[11][11], int point[2], char pos[2][16])
    {
        
        int x, wrong, flag
       for(i=0;i<2;i++) // loops round  twice allowing the input of 2 points
                    {
                        if(wrong!=1) // if wrong is 0 it will out put the following
                        {
                            if(i==0){printf("\n Please enter your Start point: ");} // input first point
                            if(i==1){printf("\n Please enter your Finishing point: ");} // input first point
                            
                        }
                        wrong=0;  // set wrong to 0
                        scanf("%16s", pos[i]);
                        flag = 0; // sets flag to 0 so place is invalid until found
                        for(x = 0; x < sizeof(place); x ++) {
                            if(strcmp(place[x+1], pos[i])==0) {
                                // place found
                                point[i] = x; // point at position i is set to the value of x
                                flag=1; //sets flag as 1 because its a valid place
                            }
                        }
                        if(flag==0) // place not found
                        {
                            printf("\n Invalid place name please re enter: ");
                            i--; // decrements i by 1 sooo it will loop round again
                            wrong=1;   // sets wrong to 1 so the ask for start or finsh point is not asked for again
                        }
                    }
       }
    it runs but when i put in a a valid place name it doesnt find it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading data from a text file
    By Dark_Phoenix in forum C++ Programming
    Replies: 8
    Last Post: 06-30-2008, 02:30 PM
  2. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  3. reading from text file
    By jamez in forum C Programming
    Replies: 3
    Last Post: 11-30-2005, 06:13 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM

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