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 › 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));

}

}

🌐
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
Answer (1 of 6): C is a procedure oriented language. Unlike C++ it does not have any string object support or java that has string as a primitive data type. In C string is simply an array of characters but the only condition is that it must be terminated by a null character,i.e '\0’. To convert...
🌐
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 ...
Find elsewhere
🌐
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 ...
🌐
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 ...
🌐
Medium
techactive6.medium.com › char-array-to-string-programming-in-ansi-c-language-7d7750a43372
Char Array to String — Programming in ANSI C Language | by Pedagogy Zone | Medium
March 8, 2021 - When the compiler assigns a character string to a character array, it automatically supplies a null character (‘\0’) at the end of the string. Therefore, the size should be equal to the maximum number of character in the string plus one. Like numeric arrays, character arrays may be initialized when they are declared.
🌐
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 ...
🌐
Cplusplus
cplusplus.com › forum › beginner › 113003
convert char array to string - C++ Forum
@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.
🌐
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
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…
🌐
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 ++; }
🌐
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.
🌐
Dot Net Perls
dotnetperls.com › convert-char-array-string
C# - Convert Char Array to String - Dot Net Perls
using System; // Create 3-character array. char[] array = new char[ ... 2] = 't'; // Create string from array. string result = new string(array); Console.WriteLine($"STRING: {result}"); ... Here we use the StringBuilder type to convert a char array to a string.
🌐
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.