Thread: Need help on Reading from a file

  1. #106
    Registered User lifeis2evil's Avatar
    Join Date
    Oct 2007
    Posts
    76
    ---
    Last edited by lifeis2evil; 10-25-2007 at 04:07 PM.

  2. #107
    Registered User lifeis2evil's Avatar
    Join Date
    Oct 2007
    Posts
    76
    oh wait I think i'm being slow again due to lack of sleep >_< hahaha that just means the setprecision(2); right?

  3. #108
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> that just means the setprecision(2); right?
    I guess... there's no such thing as set(w). There's setw, but that's not appropriate for this task. setprecision is the right way to go.

    >> my teacher always declares everything 1st and then does everything else hehe.
    Many people still do that, it's just not the best practice. In this case following your teacher's style for your assignment is best practice, especially if you aren't going into programming.

  4. #109
    Registered User lifeis2evil's Avatar
    Join Date
    Oct 2007
    Posts
    76

    Smile

    ---
    Last edited by lifeis2evil; 10-25-2007 at 04:07 PM.

  5. #110
    Registered User lifeis2evil's Avatar
    Join Date
    Oct 2007
    Posts
    76
    Thank you
    Last edited by lifeis2evil; 10-25-2007 at 04:21 PM.

  6. #111
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Isn't that two different things?
    About your indentation: the general idea is to make suer you have those brackets where you can easily see them so you see where something begins and ends. It's up to everyone what style you want to use, but you could back on my example how I've done it if you want.
    I always put a bracket right after an IF or a loop or something, then I intent every line of code inside that block and put the end bracket on the same level as the loop or IF or whatever:
    Code:
    for(;;)
    {
    	...
    }
    It's not a good thing to put these wherever because it's hard to see where the block ends. Consider the following:
    Code:
    for(;;)
    					{
    ...		}
    Much harder to read, valid but still harder to read. Something to think about.

  7. #112
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> have at least one assignment statement) did I do that?
    An assignment statement is where you assign a value to a variable. Any time you have something = something else, that is assignment.

    >> Whats the iostream for ?
    It is a header which has the code for cout and cin.

  8. #113
    Registered User lifeis2evil's Avatar
    Join Date
    Oct 2007
    Posts
    76
    thank you
    Last edited by lifeis2evil; 10-25-2007 at 07:26 PM.

  9. #114
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes, add
    Code:
    getch();
    Before the return statement, just like you've done at the end of your program.

  10. #115
    Registered User lifeis2evil's Avatar
    Join Date
    Oct 2007
    Posts
    76
    hehe okay thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM