1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Copying int value from .txt file and storing it into a int variable.

Discussion in 'C' started by kkd, Sep 29, 2010.

  1. kkd

    kkd New Member

    Joined:
    Sep 29, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    hi all:)

    iam new to c language so need a lil bit of help.

    there is a file called config.txt
    it contains x and y cordinates in the following format:

    i need to copy the values of all the cocordinates and store them into 4 integers variables into my program.

    the problem is when i copy the value into the integer variable, ascii value of that char gets stored.
    iam using the func fgetc. as iam new to c iam unable to do the convertion. i also tried typecasting.

    can anyone help me with the code.:confused:
    i think the code will not be long. so i wish if u can write it and explain what logic u used.

    the integer values will then be passes to plenv func pf plplot lib.
     
  2. kkd

    kkd New Member

    Joined:
    Sep 29, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    :peep: will someone come to the rescue:redface:
     
  3. kkd

    kkd New Member

    Joined:
    Sep 29, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    moderators admins :p where r u?
     
  4. jimblumberg

    jimblumberg New Member

    Joined:
    May 30, 2010
    Messages:
    120
    Likes Received:
    29
    Trophy Points:
    0
    Look into the strtok() function using the '=' as the delimiter.


    Jim
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    have patience. In 2 minutes of time span you posted 3 times and instead you could have helped someone else.
     
  6. kkd

    kkd New Member

    Joined:
    Sep 29, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    hehe sorry for that shabbir;)
    what can i do iam a born spammer. hve 2 lac posts in another forum;) but thats 3x rated:blush:
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    You will not reach double digit post count if you continue the same here.
     

Share This Page