When running my program with parameter 15, atoi returns 1. Atoi only returns the first digit. Is this supposed to happen? How to I get around it?
int _tmain(int argc, char* argv[])
{
int a = atoi(argv[1]);
}
When running my program with parameter 15, atoi returns 1. Atoi only returns the first digit. Is this supposed to happen? How to I get around it?
int _tmain(int argc, char* argv[])
{
int a = atoi(argv[1]);
}
It should convert the entire NUL-terminated string:
#include <iostream>
#include <stdlib.h>
int main() {
std::cout << atoi("15");
}
result:
15
Changing from _tmain to main fixed the issue.