473,569 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Esay Problem about "std::getli ne"

i use std::getling to read a line in unicoude file to buffer,like:
WCHAR buf[100]
wifstream in;
std::getling(bu f,in,100);

but i can't get the right result,it seems can only read by 1 byte;e.g first
word of unicode file is "0xfffe" ,if use getline ,it may 0x00ff 0x00fe in my
buffer

do you have any idea,except use c lib like fgetws
Nov 17 '05 #1
2 1966
aGAric wrote:
i use std::getling to read a line in unicoude file to buffer,like:
WCHAR buf[100]
wifstream in;
std::getling(bu f,in,100);

but i can't get the right result,it seems can only read by 1 byte;e.g first
word of unicode file is "0xfffe" ,if use getline ,it may 0x00ff 0x00fe in my
buffer

do you have any idea,except use c lib like fgetws


aGAric:

It would be nice if you would post a typo-free (preferably compilable)
example, so we could tell what you really did.

But, for starters, std::getline does not take a buffer; it takes a string.

HTH,

David Wilkinson

Nov 17 '05 #2
Dear Wilkinson,

thank you for you advice.
i am a new programmer.
"David Wilkinson" <no******@effis ols.com>
??????:uC****** ********@TK2MSF TNGP14.phx.gbl. ..
aGAric wrote:
i use std::getling to read a line in unicoude file to buffer,like:
WCHAR buf[100]
wifstream in;
std::getling(bu f,in,100);

but i can't get the right result,it seems can only read by 1 byte;e.g first word of unicode file is "0xfffe" ,if use getline ,it may 0x00ff 0x00fe in my buffer

do you have any idea,except use c lib like fgetws


aGAric:

It would be nice if you would post a typo-free (preferably compilable)
example, so we could tell what you really did.

But, for starters, std::getline does not take a buffer; it takes a string.

HTH,

David Wilkinson

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3225
by: Denis Petronenko | last post by:
Hello, how can i read into strings from ifstream? file contains values in following format: value11; val ue12; value 13; valu e21;value22; value23; etc. i need to read like file >string, but strings must be divided by ";" separator.
4
2795
by: Chen shuSheng | last post by:
I have a code: --------------------------- #include <iostream.h \\ where I assume getline() is inner. #include <stdlib.h> int main() { int max=15; char line; getline(line,max); system("PAUSE");
9
4981
by: Robin | last post by:
// Pls note that test.txt exists. #include <iostream> #include <fstream> #include <string> using namespace std; int main() { fstream fs("test.txt", ios_base::in | ios_base::app);
4
4136
by: =?Utf-8?B?Y2xlb2ht?= | last post by:
Hi, I have a C++ application that calls a function in another static library which accepts a std::string parameter. However, my VS 2005 compiler shows the following error: msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "class std::basic_istream<char,struct std::char_traits<char & __cdecl std::getline<char,struct...
7
3595
by: Ziyan | last post by:
I am writing a C/C++ program that runs in background (Linux). Therefore, normally no output would be written into standard output. However, sometimes I want to have debug message collected and sent tho network to a client so that errors and debug messages can be displayed simultaneously anywhere. I tried to use a std::stringstream to do the...
6
2372
by: bryant058 | last post by:
#include<iostream> #include<cstring> #include<string> #include<iomanip> using namespace std; int main() { string s; char *tokenptr; int space;
15
2986
by: waltbrad | last post by:
Hello. I'm studying the book "C++ Primer Plus" by Stephan Prata. In chapter 6 he gives an exercise that reads from a file. The list is thus: 4 Sam Stone 2000 Freida Flass 100500 Tammy Tubbs
3
4923
by: caoliangbj | last post by:
Hi, When I capture the SIGINT event, I encounter a probelm. Please look at the following code, if you don't press any key, the 'getline()' will block there all the time. When I press 'ctrl+c', the function 'getline()' still block there. My question is how can I exit from "getline()" while I just press 'ctrl
2
1732
by: Juha Nieminen | last post by:
I assume that using '\n' to print a newline is not portable because in some systems newline consists actually of two characters and '\n' is only one. Thus the only portable way of printing a newline character (for example with std::printf) is "\n". What does the standard say about '\n'? Can any assumptions be made about it? Or is it a...
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.