C Program For Long to String Conversion Last Updated : 03 Aug, 2022 Comments Improve Suggest changes Like Article Like Report To convert the long to string in C language we will use the following 2 approaches: Using Macros with sprintfUsing sprintf Input: long = 1234 Output: string 12341. Using Macros and sprintf C // C Program for Long to // String Conversion #include <stdio.h> #include <string.h> #define Max_Digits 10 int main() { long N = 1243; char str[Max_Digits + sizeof(char)]; sprintf(str, "%ld", N); printf("string is: %s \n", str); } Outputstring is: 1243 2. Using Sprintf C // C Program for Long to String Conversion #include <stdio.h> int main() { long x = 1234; char str[256]; sprintf(str, "%ld", x); printf("The string is : %s", str); return 0; } OutputThe string is : 1234 Comment More infoAdvertise with us Next Article C Program For Long to String Conversion L laxmigangarajula03 Follow Improve Article Tags : C Programs C Language C Conversion Programs Similar Reads C Program For Char to Int Conversion Write a C program to convert the given numeric character to integer.Example:Input: '3'Output: 3Explanation: The character '3' is converted to the integer 3.Input: '9'Output: 9Explanation: The character '9' is converted to the integer 9.Different Methods to Convert the char to int in CThere are 3 mai 3 min read C Program For Int to Char Conversion To convert the int to char in C language, we will use the following 2 approaches: Using typecastingUsing sprintf() Example: Input: N = 65 Output: A1. Using TypecastingMethod 1:Declaration and initialization: To begin, we will declare and initialize our integer with the value to be converted.Typecast 2 min read Converting String to Long in C Here, we will see how to build a C Program For String to Long Conversion using strtol() function. Syntax: long int strtol(char *string, char **ptr, int base)The first argument is given as a stringThe second argument is a reference to an object of type char*The third argument denotes the base in whic 4 min read Convert String to int in C In C, we cannot directly perform numeric operations on a string representing a numeric value. We first need to convert the string to the integer type. In this article, we will discuss different ways to convert the numeric string to integer in C language.Example:Input: "1234"Output: 1234Explanation: 6 min read C Program to Find the Length of a String The length of a string is the number of characters in it without including the null character (â\0â). In this article, we will learn how to find the length of a string in C.The easiest way to find the string length is by using strlen() function from the C strings library. Let's take a look at an exa 2 min read Like