Thread: how to solve this problem???

  1. #1
    moon
    Guest

    how to solve this problem???

    hi,everyone:
    i'm beginner, this time i want to ask something about how to write and read the file in C++.....

    i doing a program like this:
    cin.getline(object[a].value,30);

    so to write the file,i wrote like below:
    writefile>>cin.getline(object[a].value,30);

    then, i key in the word like "hello" in the screen,but the output inside the file become like this...004D760.......so what is the problem????anyone got the idea!!!

    moon

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    break it down into steps. first get the input from the user into the array and then write the contents of the array to a file. Compact code is not necessarily the right way to go.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    also use the right operator << not >>
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    moon
    Guest

    how to solve this problem???

    hi,

    oh,thanks,guy ..i solve it already.... then my next problem will be the character array...... u know by using cin.getline,i cant read all the thing that i type in in the read file.......so do u got any idea .....

    then my second question is about the date!!!! how to make sure that the user only can use DD/MM/YYYY format to key in the date,else the thing that they got error message......

    that all......hope somebody will reply it soon.....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Solve This Problem Within 3 Hr Urgent Need
    By annum in forum C Programming
    Replies: 12
    Last Post: 10-04-2009, 09:56 AM
  2. problem solve
    By coolnarugodas in forum C Programming
    Replies: 7
    Last Post: 04-26-2005, 12:31 PM
  3. Replies: 2
    Last Post: 04-25-2005, 11:59 AM
  4. Bubble Sort / selection problem
    By Drew in forum C++ Programming
    Replies: 7
    Last Post: 08-26-2003, 03:23 PM
  5. problem cant solve please help.
    By sarah in forum C Programming
    Replies: 6
    Last Post: 09-03-2001, 01:32 PM