I have a method in a class implemented like this:
int foo (const char* filename, bool flg)
{
FILE *fp;
char *buffer, *tokstr, *tmp;
size_t size, toksize;
unsigned int i;
if ((fp = fopen(filename, "r")) == NULL)
return FILE_READ_ERROR ;
if (flg) {
buffer = NULL;
if (getline(&buffe r, &size, fp) == -1) { // <- COMPILER BARFS HERE
!
......
}
}
}
Error message I'm getting is this:
myfile.cpp(1033 ): error C2780: 'std::basic_ist ream<_Elem,_Tra its>
&std::getline(s td::basic_istre am<_Elem,_Trait s>
&,std::basic_st ring<_Elem,_Tra its,_Alloc> &)' : expects 2 arguments - 3
provided
Any ideas how I can use getline using file pointer? 2 6015
Hello, Any ideas how I can use getline using file pointer?
Nope, try this instead:
#include <string>
#include <fstream>
....
std::ifstream f("myfile.txt") ;
std::string line;
std::getline(f, line);
....
Good luck,
Tilman
Bit Byter wrote: I have a method in a class implemented like this:
int foo (const char* filename, bool flg) { FILE *fp; char *buffer, *tokstr, *tmp; size_t size, toksize; unsigned int i;
if ((fp = fopen(filename, "r")) == NULL) return FILE_READ_ERROR ;
if (flg) { buffer = NULL;
if (getline(&buffe r, &size, fp) == -1) { // <- COMPILER BARFS HERE ! ...... } } }
Error message I'm getting is this:
myfile.cpp(1033 ): error C2780: 'std::basic_ist ream<_Elem,_Tra its> &std::getline(s td::basic_istre am<_Elem,_Trait s> &,std::basic_st ring<_Elem,_Tra its,_Alloc> &)' : expects 2 arguments - 3 provided
Any ideas how I can use getline using file pointer?
You can't - you are trying to mix two different parts of the C++
standard libraries, stdio and IOstreams. For stdio, use fgets instead of
getline. For IOStreams, use std::ifstream rather than FILE*.
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bruce Davis |
last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded
tkinter gui application. The problem appears to be a deadlock condition
when a child thread pops up a
Pmw dialog window in the context of a main window. The problem does not
occur on HPUX or Linux. The following simple example code illustrates
the problem and the work around
I've come up with; However, I'd like, very much, to get rid of the kludgy
work around....
|
by: David Morgan |
last post by:
Hi
This is a really weird problem. We have a website that has been running for
about six months with no problems. We have recently moved it to a new
server with a new ISP. The server is of a much higher specification as is
the bandwidth etc. offered by the ISP.
The move went smoothly although some users are reporting problems with a
couple of ASPs that return large amounts of HTML e.g. 1181170 bytes (I just
checked or 13464 bytes...
|
by: Kostatus |
last post by:
I have a virtual function in a base class, which is then overwritten by a
function of the same name in a publically derived class. When I call the
function using a pointer to the derived class (ClassB* b; b->func(); ) the
base-class function is called instead of the new function in the derived
class. All other similar functions (virtual in the base class and
overwritten in the the derived class) work fine, it's just this one
function. ...
|
by: Keith Dewell |
last post by:
Greetings!
My current job has brought me back to working in C++ which I haven't
used since school days. The solution to my problem may be trivial but
I have struggled with it for the last two days and would appreciate
this group's helpful expertise.
My problem may be related to mixing the C and C++ languages together.
Namely, I have a struct which I cannot change (as legacy code)
similiar to this (I will change the names throughout as...
|
by: Refky Wahib |
last post by:
Hi
I need Technical Support
I finished a Great project using .Net and SQL Server and .Net Mobile
Control
My Business case is to implement this Program to accept about 1
Million concurrent users
So I designed the project as master Node that has all administration
| |
by: Sudesh Sawant |
last post by:
Hello,
We have an application which communicates using remoting. There is a server
which is a Windows Service. The server exposes an object which is a
singleton. The client is a Web Application which makes calls to the service.
We are using tcp channel which is using binaryformatter by default. The
problem is that after a certain number of remoting calls the calls dont get
through to the server. The client application makes the call and...
|
by: Peter Olcott |
last post by:
www.halting-problem.com
|
by: Tamblyne |
last post by:
This problem has got to have a simple solution and I can't be the first
person who has ever handled it. Perhaps Google is no help because I'm
not using the right terms? (I did find one post on-point, but no one
responded to it.)
I have a two column layout with a header and a footer. If the "content"
is longer than the "navigation", there is no problem. However, if the
content is shorter than the navigation, the navigation menus...
|
by: Jon Slaughter |
last post by:
I'm having a little trouble understanding what the slicing problem is.
In B.S.'s C++ PL3rdEd he says
"Becayse the Employee copy functions do not know anything about Managers,
only the Employee part of Manager is copied. "....
and gives the code above as
.....
|
by: James Griffiths |
last post by:
Here is a report I've written about a printing problem that is being
experienced by a particular company for whom I had developed a A97 system.
After upgrading to Win XP and AXP, some printing problems have arisen. My
investigations show that it is not related to the particular system I
developed. but is affecting Access in general. So, has nothing to do with
reports being set to print to a default printer (which they all are) or to a...
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |