Thread: [BIG HELP:] File Reading and Writing in C

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    5

    [BIG HELP:] File Reading and Writing in C

    hello guys!!! pls help me with my probem..

    i just want to make a simple database like,,

    the program will ask the user if he wants to edit the existing info. in the "printf", but if he edit it, the details he typed will store in a .TXT file,

    for ex.:


    #include<stdio.h>
    main()
    {
    printf("I am .R.");
    /*then the program will ask if the user wants to edit the details in "printf", if the user want it, then the program wil provide a .txt file, that will be the database of the program where the details will be stored if the user edited the "printf".*/


    pls help me guys... ASAP pls.. tnx!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Well, besides printing a prompt, you should read the file for the existing contents, and the write to the file what the user provides.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Sounds like a homework assignment to me. You need to post up what you have tried so far and we can go from there. Without that, take a look at C Made Easy Tutorials. They will get you headed in the right direction.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  4. #4
    Registered User
    Join Date
    Sep 2011
    Posts
    5
    Quote Originally Posted by AndrewHunter View Post
    Sounds like a homework assignment to me. You need to post up what you have tried so far and we can go from there. Without that, take a look at C Made Easy Tutorials. They will get you headed in the right direction.
    i just want a example.. because i'll use that in my program.. tnx to your respond...

  5. #5
    Registered User
    Join Date
    Sep 2011
    Posts
    5
    update...

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    1) Please don't bump threads... and especially not after only 4 minutes!

    2) No; we're not going to give you code so you can "use that in my program"... that's scoop and poop coding and it's NOT how you learn C.

    Do you actually want to learn C programming or are you just trying to pass a course you didn't want to take in the first place?

    If it's the former... get a decent book on C ( Teach Yourself C in 21 Days is pretty good... The C Programming Language is held in very high esteem) and start with page 1... read every word, compile the examples and exercises, learn what does and does not work... review as necessary, then turn to page 2 ... by the time you get to the end of the book you should be able to write simple programs in console mode... the rest comes with experience and practice.

  7. #7
    Registered User Black_Epiphany's Avatar
    Join Date
    Sep 2011
    Posts
    15
    CommonTater, you are awesome. I am also learning C, and I find it very helpful to read a lot of tutorials and sample code, and then try and create programs that will cause you to run into problems and have to solve them. Good luck to you kal27 .

  8. #8
    Registered User
    Join Date
    Sep 2011
    Posts
    5
    Quote Originally Posted by CommonTater View Post
    1) Please don't bump threads... and especially not after only 4 minutes!

    2) No; we're not going to give you code so you can "use that in my program"... that's scoop and poop coding and it's NOT how you learn C.

    Do you actually want to learn C programming or are you just trying to pass a course you didn't want to take in the first place?

    If it's the former... get a decent book on C ( Teach Yourself C in 21 Days is pretty good... The C Programming Language is held in very high esteem) and start with page 1... read every word, compile the examples and exercises, learn what does and does not work... review as necessary, then turn to page 2 ... by the time you get to the end of the book you should be able to write simple programs in console mode... the rest comes with experience and practice.
    no just an example of the code so that i could analyze it, testing it, and may make code. in that case, i learned to that code... i'm not up to the sake of completion, i just need a simple code so that i can make advance code. tnx to your respond...

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Trust me Kal ... you're not going to learn C by memorizing code snippets... The only way I know to make something this complex actually sink in and stay sunk in is through a protracted course of deliberate study.

    (Hint: There will be plenty of code snippets in your text books... )

  10. #10
    Registered User
    Join Date
    Sep 2011
    Posts
    5
    no,, i'll never memorize it, i will analyze it...

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Ok... let me respond to this one last time in a manner I hope you will understand...

    No.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading and writing to a file
    By rocketman50 in forum C++ Programming
    Replies: 1
    Last Post: 06-15-2010, 12:36 PM
  2. reading and writing to a file
    By tikelele in forum C Programming
    Replies: 12
    Last Post: 11-26-2007, 11:37 PM
  3. reading and writing to file
    By jrb47 in forum C++ Programming
    Replies: 3
    Last Post: 12-04-2006, 07:35 AM
  4. reading & writing to a file
    By Micko in forum C++ Programming
    Replies: 5
    Last Post: 05-08-2004, 11:57 AM
  5. Reading and Writing to a file
    By Granger9 in forum C Programming
    Replies: 0
    Last Post: 12-30-2002, 08:31 AM

Tags for this Thread