| | |
string question
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
This's got probably an easy answer but it's been puzzling me a few hours already.
The code below declares a string object and fills it character by character. I can print every single character (line 16) but I can't print the string as a whole (line 19).
Could anybody tell me why is that so and how to fix it, please?
The code below declares a string object and fills it character by character. I can print every single character (line 16) but I can't print the string as a whole (line 19).
Could anybody tell me why is that so and how to fix it, please?
cpp Syntax (Toggle Plain Text)
#include <iostream> #include <string> using namespace std; int main() { string a; cout << "String a is: " << a << endl; //Nothing expected, fine char tmp= 100; for (int i=0; i<10; i++) { a[i]= tmp; tmp++; } for (int i=0; i<10; i++) cout << a[i]; cout << "\na: " << a << endl; return 0; }
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: Help with Student Grades program
- Next Thread: Malfunctioning LOOP
| Thread Tools | Search this Thread |
api application array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive return sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






