String is used for only words or it is used for numbers ??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

String is used for only words or it is used for numbers ???

20th Nov 2020, 9:14 PM
Sindhura N
Sindhura N - avatar
4 Answers
+ 3
Arrays can be of any type. An array of characters that is NULL terminated (i.e. contains '\0') is commonly referred to as a string. Answering to your question: it is only for words.
20th Nov 2020, 9:27 PM
Davide
Davide - avatar
+ 3
You can use numbers in a c-style string...eg "1234"...but it's still a string so you can't do any arithmetic on it, you'll need to convert it to in integer type first using e.g.... atoi().
20th Nov 2020, 9:54 PM
rodwynnejones
rodwynnejones - avatar
+ 1
Strings can contain alphanumeric (A-Za-z0-9) and special characters (&#*:;'!-+.")
22nd Nov 2020, 8:01 PM
Rufai Limantawa
+ 1
There is no purely string in C, but there is char[] which you can use look-alike string. It's different from C++ which "string" does exist and in Java "String". I assume you get that already, answering your question, it can be used for numbers BUT the numbers are just as characters (visually a number, but it's actually a character, not a number), and not only words, it could be symbols as well.
23rd Nov 2020, 8:53 AM
LastSecond959
LastSecond959 - avatar