0 #include <iostream>
1 #include <iomanip>
2 #include <cstring>
3 #include <fstream>
4
5 using namespace std;
6
7 int main() {
8 char str[256];
9 int lcount=0;
10 ofstream out("convert.html");
11 out<<"<pre>";
12 while (cin.getline(str, 256)) {
13 int len = strlen(str);
14 out<<"<a name=\"line"<<lcount<<"\">"<<setw(5)<<lcount<<"</a>";
15 out<<" <font color=\"#0000FF\">";
16 for (int i=0; i<len; i++) {
17 if ('<' == str[i]) {
18 out<<"<";
19 } else if ('>' == str[i]) {
20 out<<">";
21 } else if ('&' == str[i]) {
22 out<<"&";
23 } else {
24 out<<str[i];
25 }
26 }
27 out<<"</font>"<<endl;
28 lcount++;
29 }
30 out<<"</pre>"<<endl;
31 out.close();
32
33 ifstream in("convert.html");
34 while (in.getline(str, 256)) {
35 cout<<str<<endl;
36 }
37 in.close();
38 return 0;
39 }
Wednesday, October 28, 2009
Source Code to HTML Converter
Source Code to HTML Converter - C++
Simple Function Pointer
Simple Function Pointer Program - C++
#include <iostream>
using std::cout;
using std::endl;
void fun (void) {
cout<<"hello function"<<endl;
}
typedef void (*myfun)(void);
int main() {
myfun foo;
foo = &fun;
(*foo)();
cout<<"hello world"<<endl;
return 0;
}
Thursday, October 22, 2009
Subscribe to:
Posts (Atom)