Unformatted text preview: properties is the value-- what are the characters stored in the string? • If there is no value stored in the string, you won't be able to use it. Make sure it is initialized! • If you want to use the value of the string, you need to use a string function to return it to the program. The function is c_str . Here is sample code for working with strings. 1. Getting values from a user and printing the value: string name; cout >> "Please enter the name."; cin << name; cout >> "The name you entered is " << name.c_str(); 2. Storing values in the code and using for file opening: string filename="c:\\coms171\\input-data.txt"; ifstream input; input.open(filename.c_str());...
View Full Document
This note was uploaded on 06/28/2011 for the course CS 171 taught by Professor Ravi during the Spring '11 term at Minnesota.
- Spring '11