Click here to Skip to main content
15,920,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Platform SDK Pin
David Crow1-Nov-04 4:30
David Crow1-Nov-04 4:30 
GeneralRe: Platform SDK Pin
cberam1-Nov-04 17:05
cberam1-Nov-04 17:05 
GeneralRe: Platform SDK Pin
David Crow2-Nov-04 2:24
David Crow2-Nov-04 2:24 
Generalvc++ Pin
Member 145406031-Oct-04 19:17
Member 145406031-Oct-04 19:17 
GeneralRe: vc++ Pin
kriaz31-Oct-04 20:03
kriaz31-Oct-04 20:03 
GeneralRe: vc++ Pin
vcplusplus1-Nov-04 3:07
vcplusplus1-Nov-04 3:07 
GeneralRe: vc++ Pin
John M. Drescher1-Nov-04 7:31
John M. Drescher1-Nov-04 7:31 
QuestionHow to read a character at a time from file?? Pin
ConradT31-Oct-04 19:06
ConradT31-Oct-04 19:06 
Hi all,

I'm new to C++ and am trying to write a kind of predictive text program where the text from a file will attempt to be predicted by the program. Atm I'm trying to get started by reading the text from the file a character at a time and having each character be displayed to the screen after a press of a key. I've managed to read the text and display it as a complete word but am having trouble reading and displaying it a character at a time. I've messed around with cin.get, cin.getc, cin.getchar etc and can't seem to get them to work correctly Frown | :(

Any help on how to go about doing this would be greatly appreciated, Thanks.

The short program below is how I read the text from the file and displayed it to the screen:

Note, to avoid the console window disappearing, you have to run it using CTRL+F5. If there is another way to stop it closing please let me know. I'm using MS Visual C++.NET btw.

=====================

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
char buffer[256]; // Create 256 bit character array.
ifstream file_op; // Create an output stream variable.
file_op.open("mytext.txt"); // Open the text file to read from.

while(file_op >> buffer)
cout << buffer << endl; // Display complete text (complete word)

file_op.close();

return 0;
}
AnswerRe: How to read a character at a time from file?? Pin
KRowe31-Oct-04 22:34
KRowe31-Oct-04 22:34 
AnswerRe: How to read a character at a time from file?? Pin
David Crow1-Nov-04 4:40
David Crow1-Nov-04 4:40 
QuestionA executable file which has compiled, How to insert it into IE? Pin
hou_12631-Oct-04 17:47
hou_12631-Oct-04 17:47 
AnswerRe: A executable file which has compiled, How to insert it into IE? Pin
KRowe31-Oct-04 20:34
KRowe31-Oct-04 20:34 
GeneralRe: A executable file which has compiled, How to insert it into IE? Pin
hou_12631-Oct-04 20:46
hou_12631-Oct-04 20:46 
GeneralRe: A executable file which has compiled, How to insert it into IE? Pin
KRowe31-Oct-04 21:27
KRowe31-Oct-04 21:27 
GeneralRe: A executable file which has compiled, How to insert it into IE? Pin
hou_12631-Oct-04 21:30
hou_12631-Oct-04 21:30 
GeneralArabic Language Problem Pin
chcnjg31-Oct-04 16:26
chcnjg31-Oct-04 16:26 
GeneralInstalling Visual Studio Pin
Ryan McDermott31-Oct-04 15:37
Ryan McDermott31-Oct-04 15:37 
GeneralRe: Installing Visual Studio Pin
vcplusplus31-Oct-04 16:13
vcplusplus31-Oct-04 16:13 
GeneralCompile with version.lib Pin
picasso231-Oct-04 14:55
picasso231-Oct-04 14:55 
GeneralRe: Compile with version.lib Pin
vcplusplus31-Oct-04 16:18
vcplusplus31-Oct-04 16:18 
GeneralRe: Compile with version.lib Pin
Steve S31-Oct-04 22:44
Steve S31-Oct-04 22:44 
GeneralDownloader and Install files from the WEB (Like the Windows Updates) Pin
programming31-Oct-04 12:04
programming31-Oct-04 12:04 
GeneralRe: Downloader and Install files from the WEB (Like the Windows Updates) Pin
KRowe31-Oct-04 22:29
KRowe31-Oct-04 22:29 
GeneralLoading a Resource into a Stream Pin
Member 21854431-Oct-04 12:04
Member 21854431-Oct-04 12:04 
GeneralRe: Loading a Resource into a Stream Pin
Michael Dunn31-Oct-04 18:30
sitebuilderMichael Dunn31-Oct-04 18:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.