0% found this document useful (0 votes)
98 views

C Program For Long To String Conversion - Geeksforgeeks

The document provides information on different approaches to convert a long integer to a string in C language. It discusses using macros with sprintf and using only sprintf. It then provides code examples to demonstrate each approach.

Uploaded by

Mike Thomson
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views

C Program For Long To String Conversion - Geeksforgeeks

The document provides information on different approaches to convert a long integer to a string in C language. It discusses using macros with sprintf and using only sprintf. It then provides code examples to demonstrate each approach.

Uploaded by

Mike Thomson
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Courses Tutorials Jobs Practice Contests

DSA Data Structures


Algorithms
Interview Preparation
Topic-wise Practice
C++ Java PythonCompetitive Programming
JavaScript
Machine Learning
Write & Earn
SDE Sheet
PuzzlesGFG School
Projects

Arrays in C/C++

Complete Interview
std::sort() in C++ STL
Preparation- Self

Dynamic Memory Allocation C Program For Long to String Paced Course

in C using malloc(), calloc(), EXTRA 20% OFF


free() and realloc() Conversion
Bitwise Operators in C/C++ Last Updated : 03 Aug, 2022

Core Dump (Segmentation Read Discuss


fault) in C/C++

Multidimensional Arrays in C
/ C++
To convert the long to string in C language we will use the following 2
approaches:
Converting Strings to
Numbers in C/C++
1. Using Macros with sprintf
2. Using sprintf
Left Shift and Right Shift
Operators in C/C++ Input:

What is Memory Leak? How


can we avoid?
long = 1234

Substring in C++ Output:

rand() and srand() in C++


string 1234
Different Methods to
Reverse a String in C++
1. Using Macros and sprintf
Command line arguments in
C/C++
C

Enumeration (or enum) in C


// C Program for Long to
// String Conversion
C Language Introduction #include <stdio.h>
#include <string.h>
std::string class in C++
#define Max_Digits 10
int main()
Function Pointer in C {
long N = 1243;
fork() in C char str[Max_Digits + sizeof(char)];
sprintf(str, "%ld", N);
printf("string is: %s \n", str);
Strings in C
}

Data Types in C

Structures in C Output

Power Function in C/C++

INT_MAX and INT_MIN in


C/C++ and Applications

Taking String input with


space in C (4 Different
Methods)

Pointer to an Array | Array


Pointer
Memory Layout of C
Programs
string is: 1243
Modulo Operator (%) in
C/C++ with Examples
2. Using Sprintf
Static Variables in C

Functions in C++
C

TCP Server-Client // C Program for Long to String Conversion


implementation in C #include <stdio.h>

int main()
{

long x = 1234;
char str[256];
sprintf(str, "%ld", x);
printf("The string is : %s", str);
return 0;
}

Output

The string is : 1234

Like 0

Previous Next

C Program to Print C Program To Check


Boundary Elements of Prime Number By
a Matrix Creating a Function

RECOMMENDED ARTICLES Page : 1 2 3

01 05
C Program For Double to String Converting String to Long in C
Conversion 15, Jul 22
25, Jul 22
06
02 Conversion of Struct data type to
C Program For Boolean to String Hex String and vice versa
Conversion 15, Sep 16
25, Jul 22

07
03 C Program for Decimal to Binary
C++ Program For Boolean to String Conversion
Conversion 05, Jul 17
01, Jul 22

08
04 Program for conversion of 32 Bits
Write your own strlen() for a long Single Precision IEEE 754 Floating
string padded with '\0's Point Representation
24, May 15 31, Jan 19

Article Contributed By :

laxmigangarajula03
@laxmigangarajula03

Vote for difficulty

Easy Normal Medium Hard Expert

Article Tags : C Conversion Programs, Picked, C Language, C Programs

Improve Article Report Issue


We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and
Got It !
understood our Cookie Policy & Privacy Policy

You might also like