Is this possible?

This is a discussion on Is this possible? within the C++ Programming forums, part of the General Programming Boards category; I do not have any compileable code, mostly because i am wondering if this is even possible. Is it possible ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    8

    Is this possible?

    I do not have any compileable code, mostly because i am wondering if this is even possible. Is it possible to have the user input as the name of a file you are creating, for example to put a scanf statement inside the fopen. I don't belive that works but if there are any other possbile solutions to this if you could let me know it would be greatly appreciated.

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Input to a string. Then pass this string to fopen. (But why are you using scanf and fopen in C++?)
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Not "inside the statement", since scanf doesn't return the input directly. But you can do it in steps -- scanf a filename, and use that as the argument to fopen.

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    8
    Thank you i am using these as almost practice programs as i learned C in school but no C++ class is available so im kind of halfway inbetween as i am teaching myself C++

    Thank you to both anon and tabstop

Popular pages Recent additions subscribe to a feed

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