cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
reading string from file with blanks, wh
reading string from file with blanks, why?
May 20, 2008 at 3:36pm UTC
Robson
(1)
Hi
I'm reading from the file filled with:
cplusplus do it well
using
getline(data_file, string_line);
next
cout << string_line;
and in console appears:
■c p l u s p l u s d o 0
Anybody know why there are blanks before the char and square at the beginning and 0 at the end.
Im including these libraries:
#include <iostream>
#include <fstream>
#include <string>
May 21, 2008 at 7:51am UTC
Faldrax
(324)
A guess would be the file is in Unicode with 2 bytes per character, but string line is a char array.
May 21, 2008 at 9:30pm UTC
guestgulkan
(2942)
I would be tempted to go along with
Faldrax
.
Just out of interest what program was used to create the text file that you are trying to read. Have you tired opening this file with a plain old ascii
program like Notepad??
Topic archived. No new replies allowed.