What should I do next for a (newbie) program?
Printable View
What should I do next for a (newbie) program?
I started working on a program ( just for practice ) to make a color coded html page, if it's given a C++ code file.
Right now all it does is colorizes the single-line comments.
If you want you can build on this
it is two file cc2html.cc and defs.h
defs.h
cc2html.ccCode:#define DOCUMENT_TITLE "Html Generated by cc2html"
#define DOCUMENT_BGCOLOR "white"
#define DOCUMENT_COMMENTCOLOR "red"
#define DOCUMENT_KEYWORDCOLOR "blue"
#define DOCUMENT_STRINGCOLOR "green"
#define DOCUMENT_TEXTCOLOR "black"
Code:#include <iostream.h>
#include <fstream.h>
#include <string>
#include "defs.h"
#define ADD outFile <<
using namespace std;
void html_header(ofstream &outFile);
void html_footer(ofstream &outFile);
int main(int argc, char *argv[]) {
if(argc != 3) {
cout << "error - usage : cc2html <filename>.cc <filename>.html\n";
return 0;
}
int numKeywords;
ifstream inFile(argv[1]); //the cc file
ofstream outFile(argv[2]); //the html file
html_header(outFile);
char c;
char c_next = ' ';
char str[256];
char *keywords[] = { "auto","break","case","catch","char",
"class", "const", "continue", "delete", "default",
"do", "double", "else", "enum", "extern",
"float", "for", "friend", "goto", "if",
"inline", "int", "long", "new", "overload",
"private", "protected", "public", "register", "return",
"short", "signed", "sizeof", "static", "struct",
"switch", "this", "template", "typedef", "union",
"unsigned", "virtual", "void", "volatile", "while",NULL};
//set the number of keywords
for(numKeywords = 0 ; keywords[i] != NULL ; numKeywords++)
cout << keywords[numKeywords] << endl;
//heres the loop to create the body of the document
while(inFile.good()){
c = inFile.get();
//skip whitespace
while(inFile.good() && c == ' '){
ADD ' ';
}
switch(c) {
case '/' : if(inFile.good()) {
c_next = inFile.get();
if(c_next == '/') {
ADD "<font color="<<DOCUMENT_COMMENTCOLOR<<">";
ADD c << c_next;
inFile.get(str,256,'\n');
ADD str;
ADD "</font><br>\n";
} else
ADD c << c_next;
}else
ADD c;
break;
case '\n' : ADD "<br>\n";
break;
case '<' : ADD "<";
break;
case '>' : ADD ">";
break;
case ' ' : ADD " ";
break;
case '\t' : ADD " ";
break;
default :
if(c != EOF)ADD c;
break;
}//end switch
}//end while
html_footer(outFile);
inFile.close();
outFile.close();
}//end main
void html_header(ofstream &outFile) {
ADD "<html>\n";
ADD "<head>\n";
ADD "<title>"<<DOCUMENT_TITLE<<"</title>\n";
ADD "</head>\n";
ADD "<body bgcolor="<<DOCUMENT_BGCOLOR<<">\n";
outFile.flush();
}
void html_footer(ofstream &outFile) {
ADD "</body>\n";
ADD "</html>\n";
outFile.flush();
}
I need an idea that is simple enough for a proggrammer who started about 3 weeks ago.
Why dont you create a simple calculator type program. Creat a class for each operand +-*/ and using a switch or if statement have the user select which one he wants to do. Then in each class there would be a function for getting each users numbers. So example Class add
getnumb(); // get the numbers
addnumb(); // add the two numbs
printnumb(); // print them
Try it!
Go to the Contest board. Look around until you find something you think you can do.
Just three weeks of programming....hmm....Quote:
Originally posted by fuh
I need an idea that is simple enough for a proggrammer who started about 3 weeks ago.
Make a program which asks the user for a string and then responds telling them if its an anagram ( the same backwords and forwards ) or exits if they enter "exit". For Example
Enter a string: fuh
fuh is not an anagram
Enter a string: anna
anna is an anagram
Enter a string: exit
exiting program....Goodbye!
Make a simple RPG
****rpg ****:mad: i started at least 5 weeks ago how is that poseble graphics can in last.Quote:
Originally posted by abrege
Make a simple RPG
fuh first regster then tell me your age but for now just stick with numbers or make a program that does something you need(if its made already make it again or improve it).
hope it helps
try char for words
any problems just pm (privet message)me
I wouldn't jump into anything too overwhelming (well knowing me I would but I wouldn't suggest it). How about a program that deletes files. Like del or rm.
I would take golfinguy's idea. Write a simple calculator program
How about a fighting game :D
ok, thats pretty much a virus get it on another computer and get arested:eek: . are you drunk:DQuote:
Originally posted by master5001
I wouldn't jump into anything too overwhelming (well knowing me I would but I wouldn't suggest it). How about a program that deletes files. Like del or rm.