Help needed on writing c++program takes a jpeg file name location& output it on HTML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hapa
    New Member
    • Oct 2006
    • 31

    Help needed on writing c++program takes a jpeg file name location& output it on HTML

    I want to write a program that take a name of a person and also a name of a jpeg file with known destination and create an output on an HTML format but it should also display the picture help me out it is easy to take in name using CIN and Output file can be created usuing ofstream but the problem is how can i output a picture. can some body help me out
  • macklin01
    New Member
    • Aug 2005
    • 145

    #2
    Originally posted by hapa
    I want to write a program that take a name of a person and also a name of a jpeg file with known destination and create an output on an HTML format but it should also display the picture help me out it is easy to take in name using CIN and Output file can be created usuing ofstream but the problem is how can i output a picture. can some body help me out
    It's not entirely clear what you want, but perhaps this will help get you started.

    Code:
    #include <cstdio>
    #include <iostream>
    #include <fstream>
    #include <cstdlib>
    
    using namespace std;
    
    int main( int argc, char* argv[] )
    {
     char JpegFileName [1025];
     cout << "Input jpeg filename: ";
     cin >> JpegFileName;
    
     ofstream html_file( "image.html", ofstream::out );
    
     html_file << "<html>" << endl
     << "<head>" << endl  
     << JpegFileName << endl 
     << "</head>" << \endl 
     << "<body>" << endl << "<p>" << endl
     << "<img src=\">" << JpegFileName << "\">" << endl
     << "</p>" << endl
     << "</body>" << endl
     << "</html>" << endl;
    
     html_file.close();
    
     return 0;
    }
    Now, that generated file is not entirely w3c-standards compliant, but it's easy enough to add what's required to the header of the file. (character encoding and, doctype, etc.)

    -- Paul

    Comment

    Working...