Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. file filtering

file filtering

Scheduled Pinned Locked Moved C / C++ / MFC
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    karmendra_js
    wrote on last edited by
    #1

    i wnat to create a file to store a list of ids and name. the logic should be such that when i give id it should return name. so what kind of storage format i should go for to make my retrival easy.

    Mircea PuiuM T 2 Replies Last reply
    0
    • K karmendra_js

      i wnat to create a file to store a list of ids and name. the logic should be such that when i give id it should return name. so what kind of storage format i should go for to make my retrival easy.

      Mircea PuiuM Offline
      Mircea PuiuM Offline
      Mircea Puiu
      wrote on last edited by
      #2

      Unless you are not willing to use any fancy database approach and run some queries, you could go for an ASCII file, in which each line could contain text like: 22-Name where the id is followed by a "-" and the name itself. Then you use a CStdioFile object to read the file line by line. Assuming now that you get the line info into some char chText[256] variable, you go then for something like this: char chName[256]; unsigned int ID; sscanf(chText, "%u-%s", &ID, chName); As soon you get the ID value you are looking for, you stop the process of reading the file, close the file and return chName I'm pretty sure, some other ways exist as well :-)) SkyWalker

      1 Reply Last reply
      0
      • K karmendra_js

        i wnat to create a file to store a list of ids and name. the logic should be such that when i give id it should return name. so what kind of storage format i should go for to make my retrival easy.

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        karmendra_js wrote: i wnat to create a file to store a list of ids and name. the logic should be such that when i give id it should return name. In Continuation with Mr. Puiu, if you like to have light Database approach .... you can try embedded database like Sqlite:- here is an article related to it :- http://www.codeproject.com/database/vmembedded_db_cpp.asp[^] http://www.codeproject.com/database/CppSQLite.asp[^]

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups