C++ program to HTML

This is a discussion on C++ program to HTML within the C++ Programming forums, part of the General Programming Boards category; does anyone know how to transfer inputted information from C++ program to an html file and how to go about ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    72

    C++ program to HTML

    does anyone know how to transfer inputted information from C++ program to an html file and how to go about doing this. ALso, if anyone has any examples, i would really like to see them.

    Also need some tutorial sites on how to complete this task.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    ?

    if you know how to write html in a text editor you're half way there.

    the other half is knowing how to output a text file. use ofstream. simple as that.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    tgm
    tgm is offline
    Registered User tgm's Avatar
    Join Date
    Jun 2002
    Posts
    150
    Do you mean CGI?

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    72
    i dont know, i just want to know how i can create a program which will transfer information from variables into a website and display it there.

  5. #5
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Code:
    #include <fstream.h>
    
    int main()
    {
       ofstream WriteFile;
       WriteFile.open("MyHomepage.html", ios::out);
    
       int MyVar = 345;
    
       if(!WriteFile.fail())
       {
          WriteFile << "<HTML>" << endl;
          WriteFile << "<HEAD>" << endl;
          WriteFile << "<TITLE>My homepage</TITLE>" << endl;
          WriteFile << "</HEAD>" << endl;
          WriteFile << "<BODY>" << endl;
          WriteFile << "<H1>Welcome to my homepage!</H1>" << endl;
          WriteFile << "My variable has the value: " << MyVar << endl;
          WriteFile << "</BODY>" << endl;
          WriteFile << "</HTML>" << endl;
    
          WriteFile.close();
       }
       return 0;
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  6. #6
    Registered User
    Join Date
    Sep 2002
    Posts
    72
    is there any other codes i have to know like how to input information onto the internet?

  7. #7
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    oh man, I know what you're after! HA.

    Ok, there are two ways this is normally done. FTP and Frontpage extensions. For either you'll have to learn Winsock or WinInet. For FTP (the more likely) you'll need to learn the FTP protocol. I'm not sure but you sound like you might be a beginner and I don't suggest you try to do it this way.

    Can anyone suggest if maybe FTP can be done commandline perhaps using system()?

    edit: don't think that "beginner" stuff was meant to be insulting. It wasn't.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  8. #8
    Registered User
    Join Date
    Sep 2002
    Posts
    72
    i am a beginner, and i dont it as an insult because your always a beginner when you start new. I am greatful for your help. I would like to know the easiest way that this type of task can be done. That code above is great but looking for a bit more advanced piece encorporating the above code with a bit more flashier commands

  9. #9
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    perhaps it would help if you explain what you're trying to pull off here. I'm guessing sort of an html editor that will save up to the web?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  10. #10
    Registered User
    Join Date
    Sep 2002
    Posts
    72
    im trying to create a program where you can update information on a webpage through a C++ program. The site is not on the web, but i want it to be an html file. Like, I would like to add new information to a site, delete information off the site.

  11. #11
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    The site is not on the web
    This means the site is on your hard drive? If that's the case you're just talking about writing out to a file as we mentioned before. The "template" for the thing can just be written out by the program as Magos has shown (I haven't exactly tested his code though)
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  12. #12
    Registered User
    Join Date
    Sep 2002
    Posts
    72
    what if it were write on the web, hot would it work

  13. #13
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by niroopan
    That code above is great but looking for a bit more advanced piece encorporating the above code with a bit more flashier commands
    Flashier commands? Umm, not sure what you mean. If it's a nicer look of the page you're searching for, then you should learn HTML.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  14. #14
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    ok, like I said. if it's on your hard drive you just write it. but....

    if you're trying to write to the web, you should write to your hard drive first and then FTP it up to the server. I think WinInet might be your best bet for writing it to the server.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  15. #15
    Registered User
    Join Date
    Sep 2002
    Posts
    72
    if i wanted the user to type in a paragraph, which contains a massive number of characters, how would i go about doing this.

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

Similar Threads

  1. Access HTML from a program.
    By azjherben in forum Networking/Device Communication
    Replies: 13
    Last Post: 06-05-2009, 02:55 PM
  2. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 08:48 AM
  3. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM
  4. get program to open a html file
    By task in forum C Programming
    Replies: 14
    Last Post: 11-09-2001, 11:20 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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