By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,603 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,603 IT Pros & Developers. It's quick & easy.

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

P: 31
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
Nov 16 '06 #1
Share this Question
Share on Google+
1 Reply


100+
P: 145
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.

Expand|Select|Wrap|Line Numbers
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. int main( int argc, char* argv[] )
  9. {
  10.  char JpegFileName [1025];
  11.  cout << "Input jpeg filename: ";
  12.  cin >> JpegFileName;
  13.  
  14.  ofstream html_file( "image.html", ofstream::out );
  15.  
  16.  html_file << "<html>" << endl
  17.  << "<head>" << endl  
  18.  << JpegFileName << endl 
  19.  << "</head>" << \endl 
  20.  << "<body>" << endl << "<p>" << endl
  21.  << "<img src=\">" << JpegFileName << "\">" << endl
  22.  << "</p>" << endl
  23.  << "</body>" << endl
  24.  << "</html>" << endl;
  25.  
  26.  html_file.close();
  27.  
  28.  return 0;
  29. }
  30.  
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
Nov 17 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.