answersLogoWhite

0


Best Answer

Here is an example:

// Example.cpp : Defines the entry point for the console application.

//

#include <stdio.h>

int main();

{

char example; /*Giving example the initialization char*/

printf("What value do you want example to have: ");

scanf("%s", example); /*This is where the value you have entered is being assigned to example*/

printf("Hello %s", example);

return 0;

}

Here is the program running:

What value do you want example to have: dude

Hello dude

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can you let the user enter a string and store it into a char array in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

In C programming a character variable can at a time store how many characters?

You can store one, however if you make a char array: char[50]; You can make a string out of your array of characters.


How many constructors are there for the string class?

The String class has multiple Constructors. Some of them are: 1. String - new String(String val) 2. Character Array - new String(char[] array) 3. Character Array with index positions - new String(char[] array. int start, int end)


How do you store a string of letters for example abcdeabcde each to an array?

In C programming you would use the following: char a[] = "abcdeabcde"; If you wish to create an array with more than one string, use an array of character pointers instead: char* a[] = {"abcde", "fgh", "ijklm", "nopq", "rstu", "vwxyz"};


What is return type of string in c?

In C programming, a string doesn't have a specific return type as it's essentially an array of characters. So, if a function is returning a string, it should be declared to return a pointer to a char (char*), since a string in C is represented as an array of characters terminated by a null character ('\0').


In java is A string the same thing as a char?

No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.

Related questions

In C programming a character variable can at a time store how many characters?

You can store one, however if you make a char array: char[50]; You can make a string out of your array of characters.


How many constructors are there for the string class?

The String class has multiple Constructors. Some of them are: 1. String - new String(String val) 2. Character Array - new String(char[] array) 3. Character Array with index positions - new String(char[] array. int start, int end)


How do you store a string of letters for example abcdeabcde each to an array?

In C programming you would use the following: char a[] = "abcdeabcde"; If you wish to create an array with more than one string, use an array of character pointers instead: char* a[] = {"abcde", "fgh", "ijklm", "nopq", "rstu", "vwxyz"};


What is the difference between string and char array?

3 differences.................. 1. length wise.... 2.initialization 3. null terminated length of char array is differ from string........ initialization of string is differ from char....... and string is null terminated...........


What is return type of string in c?

In C programming, a string doesn't have a specific return type as it's essentially an array of characters. So, if a function is returning a string, it should be declared to return a pointer to a char (char*), since a string in C is represented as an array of characters terminated by a null character ('\0').


In java is A string the same thing as a char?

No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.


What is a sequence of characters?

A sequence of characters is an array of type char, commonly known as a string.


Can you give an example of array using character variable in c program?

the example of array over charcter variables is char ["string"]


C prog to concatenate two string without using buid in function?

//String Concatination#include#includeusing namespace std;char* strcat(char*,char*);int main(){char str1[100];char str2[100];coutstr1;coutstr2;cout


What is the difference between a C plus plus string and a C-style string?

A std::string is an object that encapsulates an array of type char whereas a C-style string is a primitive array with no members. A std::string is guaranteed to be null-terminated but a C-style string is not.


How many bytes does float double long string and char store?

float usually 4 double usually 8 long is 8 but integer, unlike double string is a pointer to a memory address containing array of chars, so it doesn't have a fixed size and a char is usually 1, but i think its 2 in java


What type of data is held in a string?

String in C is basically a Character 1-D array, whose last character is a NULL ['\0']. It is declared as follows: char array_name[size]; Ex. char wiki[10];