Reading INI file in C

This is a discussion on Reading INI file in C within the C Programming forums, part of the General Programming Boards category; Hello ! How to read category and respective variable parameters in user defined .ini file? file format [Category1] val1 10 ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    1

    Question Reading INI file in C

    Hello !


    How to read category and respective variable parameters in user defined .ini file?

    file format

    [Category1]
    val1 10
    val2 20
    val3 str_id

    [Category2]
    val1 11
    val2 15
    cal3 name


    plz help

    with best regards,
    sudsi

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    Ini files are just text files, so the first thing you need to be reading about is
    - fopen
    - fgets
    - fclose

    Then you can add things like
    - find Category
    - find symbol
    - find symbol in category

    Or whatever else you want to do

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    For a properly formatted ini file on windows, you can also use the GetPrivateProfileString() and GetPrivateProfileInt() functions.

  4. #4
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    GetPrivateProfileString() and GetPrivateProfileInt()
    which header are they in - is it windows.h ?
    Monday - what a way to spend a seventh of your life

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I bet Google would tell you if you asked nice enough.

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    google's not talking to me. I bugged it with so many questions yesterday
    Monday - what a way to spend a seventh of your life

  7. #7
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    try the msdn.microsoft.com then
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  8. #8
    Registered User
    Join Date
    Sep 2004
    Posts
    123
    GetPrivateProfileInt
    GetPrivateProfileString

    Don't understand why Google didn't work ... that took me more time to post than to find!

  9. #9
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    don't blame google for your mistakes
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

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