Simple String Question (Please help simple question)

What value can strings hold

I know they hold string literals/text but can they store numbers for example this string -- Doggy200
It's text but has numbers ini


--Thank you
--I'm not a Begginer just curiosity
I'm not a Begginer just curiosity
Ughh. It's like 10 pages into any C+ textbook.

There is characters '0', '1', etc., so they can.

Note that character '2' does not equals to number 2. It is different things.
Hi @Mizfizz,
and Yes;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//str_s.cpp
//##

#include <iostream>
#include <string>


using namespace std;


int main(){


string str="TextAndNumbers123";

cout<<str<<endl;

return 0; //indicates success
}//end of main
Eyenrique-MacBook-Pro:Desktop Eyenrique$ ./str_s 
TextAndNumbers123
Thank you so much guys

and im reading accelrated and im on the chapter on strings and havent read it yet

so what about insiged ints,chars,strings,pointers

what are they

are they any diffrent to what they do
so what about insiged ints,chars,strings,pointers

what are they

are they any diffrent to what they do
They are different types. In some cases they are completely different types. I suggest you to read your book. It should tell you about pointers, characters, integers and more. Also you can look int C++ tutorials on this site: http://www.cplusplus.com/doc/tutorial/
or another: http://www.learncpp.com/

Also: do not just read. Solve problems book present you, try to come up with ideas how you can use freshly learned stuff. Remember, in programming theory is nothing without practice. You should program. A lot. Do not think you will learn everything (or something at all) just by reading books.
I know but my book is more pratical its a unique apporach it covers the conepts throught praticals and not in sections like other tutorials
> What value can strings hold

A sequence of characters. 'a' is a character; '1' is also a character.


> can they store numbers

They can store a sequence of characters some or all of which are which are literal digits.

1
2
3
4
5
6
7
std::string str = "1234" ; // sequence of characters '1', '2' '3', '4'

int n = 1234 ; // number  (integer with a value of 1234)

str += "25" // append the characters '2' and '5'; becomes '1', '2' '3', '4', '2' '5'

n += 25 ; // add the number 25; becomes 1259 
Topic archived. No new replies allowed.