Question:
How do I put information into a list in notepad using a C program?
mike
2010-03-31 07:00:55 UTC
I want to put a list of information into notepad using a C program where it stores different book details, which can then be accessed and altered e.g.
Lord of the Rings, J.R.Tolkien, 212102, Available etc..
Is it possible to also search this information? (just want a yes/no here as I am currently reading on this bit)
My idea is using fopen to open a file, then print_f to type the information into it, but is it really this simple and can it still be read from this? My main concern is how to then reaccess it and alter it's information... is there a 'find' function like there is in MATLAB for C to find the book? and would it possibly be easier to instead of put it in 1 list, put each detail in seperate files? I'm just wondering whether this is possible though as they would all need to stay in order...
Thanks for your help
Five answers:
Odwin Oddball
2010-03-31 07:12:12 UTC
Notepad is just a program that reads and writes to Text files.



Reading and writing text files is very simple in C, heres a basic file tutorial:



http://www.exforsys.com/tutorials/c-language/file-management-in-c.html



C itself does not contain robust functions like text file searching. This type of function is something you will have to write yourself or find on the internet.



Google is your best friend for coding questions. Asking them here will mostly get you no where unless you just get lucky. There are a wealth of websites out there devoted to programming, and especially for C/C++/C#.
Andrew
2010-03-31 07:31:21 UTC
My C is a bit rusty, so I'll have to keep things a bit more generic.



Notepad just reads text files. Programming languages only write text files, unless you get fancy. So yeah, if I recall correctly, it's just fopen and print_f. If you specifically want to make it easy to open in Notepad, make sure the filename ends in ".txt", like "books.txt". That's all. Simple.



What you're talking about, you would usually read in the data using a loop, search it using a loop, modify it using a loop, write it back using a loop. I remember in Turbo Pascal there was something called Records, which was a collection of variables. So I could declare that variables of type Book have a string called Title, a string called Author, an Integer called ID, and a Character called Status, and I want a variable called Library which is a 20 element Array of Book. Library(1).Title would give me the Title of the first book. "FOR X=1 to 20" then "Library(X).Title" would loop through all the titles. I could also add a variable that was a pointer to another Book, then I would just chain them together and not have a limit of 20. I would think C would have something in this vein, I would program like that.



Alternately you can KEEP it stored in the file, reading, checking, modifying as you search one-by-one through the file. That will result in more processing and file accessing, and a slow search, but FAR less memory, you only have to remember one book at a time.



So, to clarify, no there isn't a Find (although Notepad has one), you have to program it yourself.
joanie
2016-04-29 05:24:32 UTC
If you wish to teach your little kid to learn popular phrases that will probably encounter and which are exceptions to basic phonetic rules then what you need is here now https://tr.im/Wit6w , Children Learning Reading program.

 Children Learning Reading is a phonetic centered studying system. Which means it first shows your son or daughter the words of the alphabet and the sounds they make. After that it applies that understanding to simply help your child figure out words on the basis of the appears the letters make. The program is designed to show the fundamental "code" for reading initially. Just following it's been learned are exceptions, troubles, and modifications introduced.
anonymous
2016-06-01 05:06:15 UTC
sorry, but i don't know the answer to that. i understand how you feel because with him being secretive and all, it does bring up cause for suspicion. personally i would just ask my husband to ease my suspicions by opening the account to let me see it......if he declines then you might have some issues there. personally, in my marriage both my husband and i trust each other and we both fear God's judgement too much to commit adultery.
anonymous
2010-03-31 07:19:46 UTC
filestream reading and writing


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...