string to int c
int isNumber(char s[])
{
for (int i = 0; s[i]!= '\0'; i++)
{
if (isdigit(s[i]) == 0)
return 0;
}
return 1;
}
atoi(str) is unsafe
This is the prefered method:
(int)strtol(str, (char **)NULL, 10)#include<string>
string str1 = "45";
string str2 = "3.14159";
string str3 = "31337 geek";
int myint1 = stoi(str1);
std::cout<<stoi(str1);
Also in C:
- C \r
- vifm preview images
- terminal size in c
- fgets c
- read from stdin c
- how to define a enum in c
- fa fa-facebook
- how to change the mapping from jkil to wasd in vim
- With a suitable example, explain increment, decrement and compound assignment operators
- FILE*
- puts without newline c
- for statement in c
- boolean c
- c program to swap two arrays
- leer un archivo en c
- c zero out array
- Square Root without square root.
- how to mutex lock in c
- TBufDataset
- imprimir matriz
- how to open a website in c
- declare variable in c
- two bytes to int c
- memset c