Re: converting string into integer




priyanka wrote:

Hi there,

I want to convert a String into integer.

I get the string froma file using :

string argNum;
getline(inputStream,argNum);

What is this getline function you're speaking of ?

I now need to convert argNum into integer.

I tried to use

int a = atoi(argNum);

But I got errot message :error: cannot convert `std::string' to `const
char*' for argument `1' to `int atoi(const char*)'

Since this std::string thingy is not C you were bound to get an error.
By the way , C++ questions should be asked at comp.lang.c++

And for the getline function, the argNum must be a string variable.

Can anyone please tell me how to convert argNum into integer ?

If argNum is pointer to char , then you use atoi. In C that is.

Spiros Bousbouras

.



Relevant Pages

  • converting string into integer
    ... I want to convert a String into integer. ... I get the string froma file using: ... I now need to convert argNum into integer. ... char*' for argument `1' to `int atoi' ...
    (comp.lang.c)
  • Re: Brian Kernighan, maybe Im not worthy, maybe Im scum
    ... conformant string. ... int repeats, reps; ... ref satisfierLength); ...
    (comp.programming)
  • RE: Controling Modal Dialogs (Solution)
    ... doesn't return until the 'modal' browser returns. ... string varOptions) ... public void DocumentComplete ... int rc = winDisp.Invoke(rgDispId, ref guid, 0, ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Gcc compatible header file
    ... A string collection is a table of zero terminated strings that will grow ... typedef struct _StringCollection StringCollection; ... int; ... bool; ...
    (comp.lang.c)
  • Kernighan and Pikes "Beautiful" Code
    ... conformant string. ... int repeats, reps; ... ref satisfierLength); ...
    (comp.programming)