Sunday, July 12, 2009

C++ help please?

im making a text editor please look at the code and tell me my problem thanks.





#include %26lt;stdio.h%26gt;


#include %26lt;iostream.h%26gt;


#include %26lt;fstream.h%26gt;


#include %26lt;string.h%26gt;


using namespace std;





int main()


{


system("@echo off");


cout %26lt;%26lt; "1. create a file \n 2. open file";


int choice;


cin %26gt;%26gt; choice;


switch (choice) {


case 1 :


int fname;


cout %26lt;%26lt; "filename and location.";


cin %26gt;%26gt; fname;


ofstream file;


file.open(fname);


file.close();


cout %26lt;%26lt; "how many lines do you want in the file?";


int lines;


cin %26gt;%26gt; lines;


if (lines = 1){


char lineA;


cin %26gt;%26gt; lineA;


}


if (lines = 2){


char lineA;


cin %26gt;%26gt; lineA;


char lineB;


cin %26gt;%26gt; lineB;


}


if (lines = 3){


char lineA;


char lineB;


char lineC;


cin %26gt;%26gt; lineA;


cin %26gt;%26gt; lineB;


cin %26gt;%26gt; lineC;


}


if (lines = 4){

C++ help please?
Here's one problem:


The if checks are assigning lines to a number instead of comparing lines to a value.





change " if(lines = 1) " to " if(lines == 1) "


and change that for every if check.


No comments:

Post a Comment