d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > File Reading And Writing
Add Reply New Topic New Poll
Member
Posts: 1,307
Joined: Apr 9 2007
Gold: 1,676.45
Oct 7 2016 10:30pm
Ok so I need to create a program in ncuses that acts like a text editor. So far I have it fully functional to where it reads the file and prints it on the screen and the user can use the arrow keys to move the cursor to add or remove characters. When I opened the file I used the following code:

Code
FILE *fp;
char *fileArray = new char[fileSize];
fp = fopen(fileName, "r+");


The problem that I'm running into is when I try to write the changes the user made back to the file itself. I'm looking for something that could read the ncurses window and return the character but I've tried this:

Code
ofstream file("new.txt");
move(0,0);
for(int b=0; b<row; b++){
for(int q=0; q<col; q++){
chtype ret = mvinch(b,q);
file << ret;
}
}


But the new file is just a bunch of random number so I'm not sure what to do here. A little guidence would be great. Thanks

This post was edited by ice060788 on Oct 7 2016 10:48pm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Oct 7 2016 11:15pm
Chtype is the character as well as attributes such as bold/italics and color codes. This is likely a type of struct and you will need to access its members to find the value of the current position you are trying to parse.

I suggest looking at the documentation and finding another function.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll