Noob needing help

This is a discussion on Noob needing help within the C Programming forums, part of the General Programming Boards category; Sorry I am kinda new to C as well as kinda new to the world of programming :\ I can ...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    1

    Exclamation Noob needing help

    Sorry I am kinda new to C as well as kinda new to the world of programming :\ I can only program in python so far.

    Well, anyway i hope you can help me.

    I have a .txt file that would be something like this..

    blablabla
    2
    1
    tttt
    3
    2

    A name followed by 2 numbers, and i want to store this information on an array so i can somehow work with it, 1 element of that array being each line. Maybe storing in 2 arrays would be better since there are 2 different types. Anyway. How could i do that?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Open the file and read each line into a char array -- ie, you would have a 2D char array:

    Code:
    char data[10][256];
    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

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Youthm View Post
    Sorry I am kinda new to C as well as kinda new to the world of programming :\ I can only program in python so far.

    Well, anyway i hope you can help me.

    I have a .txt file that would be something like this..

    blablabla
    2
    1
    tttt
    3
    2

    A name followed by 2 numbers, and i want to store this information on an array so i can somehow work with it, 1 element of that array being each line. Maybe storing in 2 arrays would be better since there are 2 different types. Anyway. How could i do that?
    Well, first you hit the books and read up on file i/o in C... try the exercises they give you, do the quiz program... repeat as necessary.
    Then you sit yourself down and figure out exactly what you need to do --step by step-- to accomplish your goal.
    Once you understand the problem... you can start working on designing the solution.

    The last thing you will do is write source code.

    So, "i want to store this information on an array so i can somehow work with it"... just ain't gonna get the job done.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C newbie needing help.
    By Enzo in forum C Programming
    Replies: 5
    Last Post: 12-28-2009, 03:27 AM
  2. Noob needing some help and insight
    By punktilend in forum C++ Programming
    Replies: 1
    Last Post: 02-24-2009, 03:41 PM
  3. Noob programmer needing help.
    By Gamemaniac00 in forum C++ Programming
    Replies: 3
    Last Post: 11-10-2006, 06:31 AM
  4. Needing help please....
    By tameeyore in forum C Programming
    Replies: 2
    Last Post: 02-06-2005, 12:06 PM
  5. Newbie to C++ needing help
    By Tazwoh in forum C++ Programming
    Replies: 6
    Last Post: 03-02-2003, 11:50 AM

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