Use string conversion functions and then do math calculation - C String

C examples for String:String Function

Description

Use string conversion functions and then do math calculation

Demo Code

#include <stdio.h> 
#include <stdlib.h> 
int main()//from w  w  w .jav a  2  s  . c  om
{
   char *str1 = "12345";
   char *str2 = "12345";
   int iResult;
   iResult = atoi(str1) + atoi(str2);
   printf("\nString 1 + String 2 is %d\n", iResult);
}

Result


Related Tutorials