Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Visual c++ CString

Posted on 2003-02-25
3
Medium Priority
?
253 Views
Last Modified: 2009-12-16
Hello everybody!
Can somebody please help?
How do I read chars from a binary file into a CString in Visual c++?
...
CString text;
char c;

ifstream source(file_path, ios::nocreate | ios::binary)

//loop
source.get(c);
text+=c;

The problem: CString contains both plain text AND the binary chars!? What am I doing wrong?
0
Comment
Question by:zaratin
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 200 total points
ID: 8016672
What do you want to be in the CString?  Just the alpha-numeric characters?  Just the chars?  You could check to see if it's a printable character (using isprint) or an alpha-numeric (using isalpha) before appending it.
0
 

Author Comment

by:zaratin
ID: 8016807
Thx mnashadka!!!
isalpha(c) was the right thing!!!
many greetings
0
 
LVL 8

Expert Comment

by:mnashadka
ID: 8017187
Sorry, isalnum is what I was thinking, but either way I'm glad I could help.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question