file i/o help

This is a discussion on file i/o help within the C++ Programming forums, part of the General Programming Boards category; thanks for the help <huges>...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    34

    file i/o help

    thanks for the help <huges>
    Last edited by eric123; 07-28-2006 at 02:25 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,712
    Um, if you can write:
    cin>> text;
    What's so difficult about writing:
    a_file<<text;

    The text would be limited to some integer though.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,459
    Code:
    a_file<<"hello =) ";
    becomes

    Code:
    a_file << text;
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    34
    if i do it like that then i cant enter stuff to the file from the exe which is what i whant to do
    and what will i have learn? so i like to not do it that way

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    34
    Quote Originally Posted by Mario F.
    Code:
    a_file<<"hello =) ";
    becomes

    Code:
    a_file << text;

    not shore what u mean by this please say more

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,459
    Quote Originally Posted by eric123
    if i do it like that then i cant enter stuff to the file from the exe which is what i whant to do
    and what will i have learn? so i like to not do it that way
    Really? Have you even tried it?
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,459
    Quote Originally Posted by eric123
    not shore what u mean by this please say more
    What is there left to say? Laserlight and I provided you with the same solution. replace your code as explained.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    Registered User
    Join Date
    Nov 2005
    Posts
    34
    lol didnt read it right and no iv never tried it

    so i tri it and whin i open the txt i get the same number every time no matter what i right

    4198592??? any ideal what that means lol or how i can make it right what i type

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,459
    Quote Originally Posted by eric123
    4198592??? any ideal what that means lol or how i can make it right what i type
    That variable text you are using to accept input and then ouput to a file is declared of type int. That is integer. It represents integral arithmetic types. What you want is text. you should declare it as a string.

    add this below "#include <cstdio>"
    Code:
    #include <string>
    and change int text; to string text;

    And now that it is working, I suggest you start from the basics instead of already trying to create a file.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  10. #10
    Registered User
    Join Date
    Nov 2005
    Posts
    34
    ty it is work lol and what you mean by basic how long can some 1 learn how to right very esey stuff <ya i no this is not that hard to you> i can do some stuff file i/o is just someting to learn i learn more and get batter this is the first time iv ever gotsometing to work useing file i/o
    ya i no i needed help but everthange i no i learn from reading and a little help here and ther
    i got a big problum whit tring to do alot fast and work on c++ for liek 12 hours then i get burned out and wount mess whit it for a long time but it makes me happy so i keep buying books alot of whats in them i still cant do but i like it =)

    so tell me what you mean by basic... i can do hello world esey rofl....

  11. #11
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,459
    Quote Originally Posted by eric123
    so tell me what you mean by basic... i can do hello world esey rofl....
    Well it meant something else before, but now means you probably should consider using punctuation when writing.

    Anyways, start with the tutorials on this website. Go one by one in the order they are presented to you. It's hard to do file I/O if you can't even understand what is an int. You will feel much more rewarded if you do so. C++ just like everything else, requires a method of learning. The order of the tutorials on this website is one such method.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #12
    Registered User
    Join Date
    Nov 2005
    Posts
    34
    Quote Originally Posted by Mario F.
    Code:
    a_file<<"hello =) ";
    becomes

    Code:
    a_file << text;

    lol just so you no whin i akset what to you mean i was looking at it like

    a_file << "text";

    not like

    a_file << text;

    >.< ya i no im a noob

  13. #13
    Registered User
    Join Date
    Nov 2005
    Posts
    34
    i cant understand all of it and like i said some times i go long time whitout working on it iv read every tutorial on this website for c++ i dont even understand hafe of it reading is not as good as noing what it means i do my best and keep going cuse i like doing it and its not like i have people that cant help me whit it only get help whit stuff like very little so if i do get a little it helps alot and agine thanks for your help=)

  14. #14
    Registered User Osaou's Avatar
    Join Date
    Nov 2004
    Location
    Stockholm, Sweden
    Posts
    69
    I whole-heartedly loathe this kind of language... But hey, whatever makes you feel cool!

  15. #15
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    > thanks for the help <huges>
    > Last edited by eric123 : Today at 09:25 AM.
    Please don't edit out your question when you've got your answer.
    It makes the rest of the thread look meaningless.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. 2 questions surrounding an I/O file
    By Guti14 in forum C Programming
    Replies: 2
    Last Post: 08-30-2004, 11:21 PM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 08:09 PM
  5. advice on file i/o
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 04:56 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21