will not output characters

#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>

using namespace std;
int read(string);
void print(ofstream&, int,char);
void space(ofstream&, int );
void newline(ofstream&);
//no global varialbes - use parameters
int main()
{ ifstream iFile; //naming ifstream
ofstream oFile; //naming ofstream
//declaring variables
string word;
int numberofchar;
int numberofspaces;
char charac;
//declaring variables for case file
const int printfunction=1;
const int spacefunction=2;
const int newlinefunction=3;
const int quitfunction=4;

iFile >> word;
// ignores first three lines of the data file
iFile.ignore(255, '\n');
iFile.ignore(255, '\n');
iFile.ignore(255, '\n');


iFile.open("Commands.txt");// open data file
oFile.open("Drawing.txt");//open results file

oFile<<"Programmer: name"<<endl;//output line into results file
oFile<<"CS 1044 Project 4 Fall 2010"<<endl;//output line into results file
oFile<<endl;//output line into results fine

while (iFile) { // start while

//switch statement which reads the function file and calls all of the functions as it goes through
//each line in the datafile
switch (read(word)){
case printfunction: iFile >> numberofchar>> charac;
print(oFile, numberofchar, charac);
break;
case spacefunction: iFile>> numberofspaces;
space(oFile,numberofspaces);
break;
case newlinefunction: newline(oFile);
break;
case quitfunction:
iFile.close();//close result file
oFile.close();//close data file
break;
default: //used when no others apply
iFile.close();//close result file
oFile.close();//close data file

}//end switch
}//end while
}//end main

//read function strings through the whole data file word
//it determines what case to go to in the switch structure
//returns the results to the switch structure
//where there it calls the other functions to output the right results
int read(string word){
if (word == "print"){
return 1;}
if (word=="space"){
return 2;}
if (word=="newline"){
return 3;}
if (word=="quit"){
return 4;}
}
//print function
//the function reads that is a print line stores the number and the character
//then it will run through the for loop outprinting the characters till the for loop is no longer valid.
void print(ofstream& oFile, int numberofchar,char charac){
for (int count=0; count <numberofchar; numberofchar++)
oFile << charac;
}
// space function
// the function reads that is a space stores the number of spaces
//then it runs through the for loop outputting the number of spaces until the loop is invalid.
void space(ofstream& oFile, int numberofspaces){
for(int count=0; count<numberofspaces; numberofspaces++)
oFile << ' ';
}
//newline function
//the function reads that is a newline.
//then it outputs a blank line
void newline(ofstream& oFile) {
oFile <<endl;
}
i can output the two lines with my name and the program number but it will not output anything else and idk why
OW! My eyes, MY EYES!!!

(use [code] blocks, then we might discuss your program :P).
http://cplusplus.com/articles/firedraco1/

-Albatross
Topic archived. No new replies allowed.