?
Solved

Visual c++ CString

Posted on 2003-02-25
3
Medium Priority
?
242 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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