Can't think of any new programs.

This is a discussion on Can't think of any new programs. within the C++ Programming forums, part of the General Programming Boards category; What should I do next for a (newbie) program?...

  1. #1
    fuh
    Guest

    Can't think of any new programs.

    What should I do next for a (newbie) program?

  2. #2
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    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
    Code:
    #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"
    cc2html.cc
    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 "&lt;";
    				   break;
    			case '>' : ADD "&gt;";
    				   break;
    			case ' ' : ADD "&nbsp;";
    				   break;
    			case '\t' : ADD "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    				    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();
    
    }

  3. #3
    fuh
    Guest
    I need an idea that is simple enough for a proggrammer who started about 3 weeks ago.

  4. #4
    Registered User
    Join Date
    Jun 2002
    Posts
    230
    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!

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    Go to the Contest board. Look around until you find something you think you can do.
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  6. #6
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    Originally posted by fuh
    I need an idea that is simple enough for a proggrammer who started about 3 weeks ago.
    Just three weeks of programming....hmm....

    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!
    Last edited by beege31337; 12-15-2002 at 07:36 PM.

  7. #7
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Make a simple RPG
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  8. #8
    Neoseeker's master master2000's Avatar
    Join Date
    Dec 2002
    Posts
    101
    Originally posted by abrege
    Make a simple RPG
    ****rpg **** i started at least 5 weeks ago how is that poseble graphics can in last.


    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

  9. #9
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    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.

  10. #10
    Shadow12345
    Guest
    I would take golfinguy's idea. Write a simple calculator program

  11. #11
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    How about a fighting game

  12. #12
    Neoseeker's master master2000's Avatar
    Join Date
    Dec 2002
    Posts
    101
    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.
    ok, thats pretty much a virus get it on another computer and get arested . are you drunk
    missles on metriods

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Starting programs
    By Molokai in forum C Programming
    Replies: 1
    Last Post: 04-16-2009, 11:10 AM
  2. Recommend upgrade path for C programs
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-22-2007, 07:32 AM
  3. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 05:42 AM
  4. executing c++ programs on the web
    By gulti01 in forum C++ Programming
    Replies: 4
    Last Post: 08-12-2002, 04:12 AM
  5. Release MFC Programs & Dynamic MFC DLL :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-18-2002, 07:42 PM

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