You're saying you have this:

char array[20]; char string[100];
array[0]='1'; 
array[1]='7'; 
array[2]='8'; 
array[3]='.'; 
array[4]='9';

And you'd like to have this:

string[0]= "178.9"; // where it was stored 178.9 ....in position [0]

You can't have that. A char holds 1 character. That's it. A "string" in C is an array of characters followed by a sentinel character (NULL terminator).

Now if you want to copy the first x characters out of array to string you can do that with memcpy():

memcpy(string, array, x);
string[x] = '\0'; 
Answer from Mike on Stack Overflow
🌐
DigitalOcean
digitalocean.com › community › tutorials › convert-string-to-char-array-c-plus-plus
Convert String to Char Array and Char Array to String in C++ | DigitalOcean
August 3, 2022 - C++ c_str() function along with C++ String strcpy() function can be used to convert a string to char array easily.
🌐
Reddit
reddit.com › r/cs50 › how do i convert a string to an array of chars in c?
r/cs50 on Reddit: How do I convert a string to an array of chars in C?
March 21, 2023 -

I know that a string is already technically an array of chars, but when I try to use toupper(string), it doesn’t work because toupper is designed to capitalize chars and not strings, per the documentation. I’ve been making it overly complicated and it’s stressing me out. So to start, I created an “int N=strlen(string);”, then created an array that’s “char upper[N];”. Then I write a for loop written as(please forgive the terrible syntax I’m about to write), “for (int i = 0; i < N; i++) { toupper(upper[j]); }”. What am I doing wrong?

🌐
Quora
quora.com › How-do-I-convert-a-char-to-string-in-C
How to convert a char to string in C - Quora
To convert a character to string in C, you can do the following · 1. Declare a char array of the size 2, i.e char arr[2]; 2.
🌐
Reddit
reddit.com › r/cs50 › simplest way to convert characters into a string? (c)
r/cs50 on Reddit: Simplest way to convert characters into a string? (C)
May 2, 2020 -

Hello everyone!

In this simple example, how can I replace the new_key string contents with the uppercase of the key string? I can print it alright with the below code, but can't find a way to store the characters in the empty string - there are always either segmentation fault errors or initializer ones.

What would be the best way to make new_key[i] be the content of toupper(key[i])?

#include <stdio.h>

#include <cs50.h>

#include <string.h>

#include <stdlib.h>

#include <ctype.h>

int main(void)

{

string key = "abcde";

string new_key[] = "";

for (int i = 0, len = strlen(key); i < len; i++)

{

char c = key[i];

printf("%c", toupper(c));

}

}

🌐
Cplusplus
cplusplus.com › forum › beginner › 113003
convert char array to string - C++ Forum
October 9, 2013 - @MikeyBoy and @coder777 -> oh i see, i didn't figure that out ( i'm just a begginer too ) ,by the way ... thanks to the two of you for the right info ... @coder777, Mikeyboy, and Tath --> the string str(aa); // worked fine and using cout instead of printf also corrected some output problems I had.
🌐
Experts Exchange
experts-exchange.com › questions › 28029644 › C-Print-char-array-as-string.html
Solved: C: Print char array as string | Experts Exchange
February 12, 2013 - If you printf with %c it will print out a single character which will be the value of string[0], but if you printf with %s it will print out ... actually i'm not sure what %s does beyond the fact that its suppose to print a string. I understand it requires an array as input, and the array has to be of chars.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › c language › how-to-convert-a-string-to-a-char-array-in-c
How to Convert a String to a Char Array in C? - GeeksforGeeks
July 23, 2025 - Explanation: The strcpy() function, copies the contents of a source string into a destination character array. This function automatically handles the copying of characters, including the null terminator ('\0'), ensuring the string is properly ...
🌐
Quora
quora.com › Can-we-assign-a-string-to-a-char-array-in-C
Can we assign a string to a char array in C? - Quora
Answer (1 of 8): You can do that in any language — take each character in the string and assign it to the next index in an array [character]. But don’t learn programming with C. It is a primitive, old, and flawed language and you will learn a lot of unimportant things and completely miss ...
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Append C-string (Char Array) to String - Programming - Arduino Forum
June 18, 2023 - As far as i have worked out: (I am probably wrong) A C-String/Char Array is Defined as char receivedChars[numChars]; When viewed contains an array like ["M","1","0","0","P","1","0","0","S","0","4","0"] Each index is considered a Char even when ...
🌐
W3Schools
w3schools.com › c › c_strings.php
C Strings
Unlike many other programming languages, C does not have a String type to easily create string variables. Instead, you must use the char type and create an array of characters to make a string in C:
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Convert char Array to String - Programming - Arduino Forum
January 29, 2019 - Hi, I am reading data from an RFID reader using software serial. The data is being received Byte by Byte and placed into a char array. The sketch below works great and displays the data perfectly, but I would like to fi…
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › convert-character-array-to-string-in-c
Convert character array to string in C++ - GeeksforGeeks
July 11, 2025 - Use the overloaded '=' operator to assign the characters in the character array to the string. Return the string. Below is the implementation of the above approach. ... // Demonstrates conversion // from character array to string #include ...
🌐
Codemia
codemia.io › knowledge-hub › path › how_to_convert_a_char_array_back_to_a_string
How to convert a char array back to a string?
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
Edureka Community
edureka.co › home › community › categories › c++ › how to convert a char array to a string
How to convert a char array to a string | Edureka Community
July 14, 2022 - Converting a C++ string to a char array is as simple as using the string's c str function and then ... transformed to string str = "This is a test."
🌐
Swift Forums
forums.swift.org › using swift
C char array to swift string - Using Swift - Swift Forums
August 18, 2022 - swift 4.2. in my swift code , i return char array as part of a structure from a c function. The print statement on the c side is proper. on c side "abcd.." shows up as "97,98,99, ...: in the swift side. And it prints the entire 16 byte array instead just of the 5 bytes. on the C side , it print ...
🌐
Arduino Forum
forum.arduino.cc › projects › general guidance
Converting char array to string - General Guidance - Arduino Forum
September 27, 2022 - char buff[1000]; int char_count = 0; bool received = false; if(Serial2.available()>0){ while(Serial2.available()>0) { buff[char_count]=Serial2.read(); received = true; char_count ++; }
🌐
Studytonight
studytonight.com › c › string-and-character-array.php
String and Character Arrays in C Language | Studytonight
Compilers to execute code in browser. ... Learn Coding! ... String is a sequence of characters that are treated as a single data item and terminated by a null character '\0'. Remember that the C language does not support strings as a data type. A string is actually a one-dimensional array of characters in C language.