int in string c

#include <stdio.h>
#include <stdlib.h>

int main() {
    char str[] = "123";
    int num;

    // Using atoi function to convert string to integer
    num = atoi(str);

    // Printing the result
    printf("The integer value is: %d\n", num);

    return 0;
}
  1. Include necessary header files: stdio.h for input/output operations and stdlib.h for the atoi function.

  2. Declare a character array str and initialize it with the string "123".

  3. Declare an integer variable num to store the converted integer value.

  4. Use the atoi function to convert the string str to an integer and assign the result to the variable num.

  5. Print the converted integer value using printf.