#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Milwaukee, WI
    Posts
    5
    Rep Power
    0

    Unhappy Write output to a file in MFC


    I am a pretty experienced programmer when it comes to Concole based C++, Java and VB. however I suck like hell at MFC. I am trying to develop a small app for my personal use which needs some output manipultion and I want to write the output to file. here is the console based output and I would like to have its MFC equivalent:

    OutFile << "[img]" <<_URL << setw(3) << setfill('0') << _Counter <<_Extension <<"[/img]" << endl;

    What I basically want to do is to create links for message boards like this where people post images, caps etc which are sequenciallu numbered: for example -


    [img] http://www.somesite.com/Images/Pic002.jpg[/img].....
    [img] http://www.somesite.com/Images/Pic500.jpg [/img]

    so how can I write the output to a file in MFC?

    Info on identifiers:

    _URL -- CString
    _Counter -- int
    _Extension -- CString

    I am using Visual Studio.NET

    Thanks

    AJ
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    138
    Rep Power
    12
    if i am right u have to use CFile in this case. Please check the help and you will be able to find how to open and close
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Milwaukee, WI
    Posts
    5
    Rep Power
    0

    Unhappy


    You are right Raghu....I know I have to use CFile. The problem here is CFile accelts a char[] and not a CString :( Also, I don't think I can use setw(), setfill() etc in CFile :( Can you help me further bhai?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    138
    Rep Power
    12
    ok there are two things here..you can convert the CString to char
    by using the getbuffer method if the CString is in ascii if it is in unicode u can use wcstombs to convert CString to character. Then use this character array to pass into your file
    you can find that getbuffer in this same forum and also u can find wcstombs in the help!!. I am sure of the syntax but can look that up
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Milwaukee, WI
    Posts
    5
    Rep Power
    0
    Cool man..I think that would help. I was thinking bout the same line after doin helluva readin on the damn internet. Hmm one last question :p :p How do I account for setw() and setfill() ... I doubt if they can be passed into the cahr array :confused:

    Thanks for ur reply

    AJ
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Milwaukee, WI
    Posts
    5
    Rep Power
    0

    Unhappy


    :mad: :mad: :mad: :mad: :mad: :mad:
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    138
    Rep Power
    12
    I have not done much of formatting in CFile.. and i really dont remember them. I dont have a book to verify so I am sorry i cant help you with the setw and setfill in MFC.
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Milwaukee, WI
    Posts
    5
    Rep Power
    0
    Originally posted by Raghuraman
    I have not done much of formatting in CFile.. and i really dont remember them. I dont have a book to verify so I am sorry i cant help you with the setw and setfill in MFC.
    Thats ok man.....I'll try to find some other crude way of formatting it that way :) Shouldn't be hard I guess. :) easy man

    AJ

IMN logo majestic logo threadwatch logo seochat tools logo