C Program to demonstrate the ‘atof’ and ‘gets’ functions.

Converting strings to numbers is a fundamental task in C — every value read from scanf, fgets, or command-line arguments arrives as a string and must be explicitly converted. The standard library in <stdlib.h> provides three simple conversion functions: atoi() (string to int), atol() (string to long), and atof() (string to double/float). For robust error …

C Program to accept a string and a substring and check if the substring is present in the given string

Checking whether one string contains another is one of the most common string operations in C. The standard library provides strstr() in <string.h> — it returns a pointer to the first occurrence of the substring in the main string, or NULL if not found. The position of the match is calculated by subtracting the start …