ok i try function atoi, it works finehere is the code
Code:
// program that transforms charicters in to integer
#include <iostream>
#include <stdio>
#include <stdlib>
using namespace std;
int main() {
char string[256];
int a;
cout << "input - x345 j5678 k345 ";
cin.getline ( string , 256 , 'k'); //k is my end sign
cout << "your line: " << string << endl;
a = atoi (string);
cout <<" a = " << a <<endl;
cin.get();
}
but why will i get an error if i try to declare
Code:
int a[4]; //it means that a can have only 4 numbers
...
a = atoi (string [3]); //here i wanna read 4 numbers from the third field on
...
Code:
string.cpp: In function âint main()â:
string.cpp:23: error: invalid conversion from âcharâ to âconst char*â
string.cpp:23: error: initializing argument 1 of âint atoi(const char*)â
string.cpp:23: error: incompatible types in assignment of âintâ to âint [4]â
ziga@debian:~$