convert string (char) to int
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char **argv)
{
char letter;
int count = 0;
int line_limit;
line_limit = atoi(argv[1]);
while ((letter = cin.get()) != -1){
cout.put(letter);
if ((letter == '\n') && (++count == line_limit))
break;
}
}
Related examples in the same category