I just begginer in the c++.... I tried to make s poor program, that read text and store it in a stuct and desplay it on the screan, and when the user want he can save it, But I didn't successI don't know exactly how to save, and I have problem with the struct when I pass it to function... Can you help Me finish this attempt.
-------
please tell me what wrong.Code:#include<iostream.h> #include<fstream.h> #include<conio.h> char FLN; static int i;//To count the letters struct page{ char pages[40][100]; }; int Save(struct page X); void main(void) { clrscr(); int L=1,C=1,CC=1,LL=1; //L=line,C=character,CC=character //in the array,LL=Line in the array1, struct page P1; while(1) { P1.pages[L][C]=getch(); // put the char the I recieve in the array if(C==80){C=1;L++;} //New Line if(P1.pages[L][C]==(char)13){L++;C=1;cout<<endl;continue;}//When Enter:New Line if(P1.pages[L][C]==19){Save(P1);continue;}//Ctrl+S to //save if(P1.pages[L][C]==char(27))break;//Esc Exits if(P1.pages[L][C]==char(8)){C--;gotoxy(C--,L);cout<<" ";i-=2;if(C==1)C=1;}//when backSpace, do backspace! gotoxy(C,L); cout<<P1.pages[L][C]; // Desplay the current letter; i++;// count letters C++; // next position in the array; } cout<<endl; for(int O=0;O<i;O++)//for loop to redispay! { if(CC==80||P1.pages[LL][CC]==(char)13) {cout<<endl;CC=1;LL++;} cout<<P1.pages[LL][CC]; CC++; } } int Save(struct page X) { int CC=1,LL=1; cout<<"Enter File name To save: "; cin>>FLN; ifstream outptfile(FLN); if (outptfile.fail()) { cout<<"Error Opening the file "<<FLN; return -1; } for(int M=0;M<i;M++) { if( (CC==80)||(X.pages[LL][CC]==(char)13) ) //PROBLEM{outptfile<<"\n";CC=1;LL++;} outptfile.write(X.pages[LL][CC],1); PROBLEM CC++; } return 0; }



LinkBack URL
About LinkBacks
I don't know exactly how to save, and I have problem with the struct when I pass it to function... Can you help Me finish this attempt.


