Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking a number represented as a string in C

Tags:

c

I would like to check if a number is larger than 0.

The 0 is in string format

How do I either

  1. Compare the value to a string representation of 0
  2. Cast the string to an int
like image 834
some_id Avatar asked Nov 30 '25 01:11

some_id


2 Answers

strtol()

like image 63
Martin Beckett Avatar answered Dec 02 '25 15:12

Martin Beckett


atoi() will convert string into integer.

like image 40
Gaurav Avatar answered Dec 02 '25 15:12

Gaurav



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!