string
请问高手:
在c/c++里面想用string类型,怎么用呢?
为什么我#include <string> 后还是不行?
问题点数:10、回复次数:12Top
1 楼shmily1280(锄禾)回复于 2005-12-16 11:14:33 得分 0
头文件加错了,不过是什么我也不知道,嘿嘿
Top
2 楼piaochen_2002(执子之手,与子偕老!)回复于 2005-12-16 11:17:03 得分 0
#include <string.h>
#include<string>// 应用string摸板类要用的头文件Top
3 楼Seu_why(Newbie)回复于 2005-12-16 11:20:56 得分 10
#include <string>
using namespace std;Top
4 楼jenhi()回复于 2005-12-16 11:31:42 得分 0
应用string摸板类要用的头文件
我就是要在程序中这样声明:
string str;
不行啊。能不能说详细点啊?Top
5 楼piaochen_2002(执子之手,与子偕老!)回复于 2005-12-16 11:44:28 得分 0
#include <string>
#include<isotream>
using namespace std;
Top
6 楼piaochen_2002(执子之手,与子偕老!)回复于 2005-12-16 11:44:51 得分 0
#include <string>
#include<iostream>
using namespace std;
Top
7 楼jenhi()回复于 2005-12-16 11:45:21 得分 0
using namespace std;
在C里这句表示什么?Top
8 楼jenhi()回复于 2005-12-16 11:46:52 得分 0
为什么还要
#include <iostream>跟
using namespace std;Top
9 楼bobob(静思)回复于 2005-12-16 11:59:44 得分 0
using namespace std;
使用标准名字空间Top
10 楼Seu_why(Newbie)回复于 2005-12-16 12:36:27 得分 0
为什么加using namespace std;
去看 C++ prime
Top
11 楼Mackz(在相互)回复于 2005-12-16 14:01:24 得分 0
Example
// string_getline_sample.cpp
// compile with: /EHsc
// Illustrates how to use the getline function to read a
// line of text from the keyboard.
//
// Functions:
//
// getline Returns a string from the input stream.
//////////////////////////////////////////////////////////////////////
#pragma warning(disable:4786)
#include <string>
#include <iostream>
using namespace std ;
int main()
{
string s1;
cout << "Enter a sentence (use <space> as the delimiter): ";
getline(cin,s1, ' ');
cout << "You entered: " << s1 << endl;;
}
Input
test this
Sample Output
Enter a sentence (use <space> as the delimiter): test this
You entered: test
Requirements
Header: <string>
Top
12 楼8000(LP)回复于 2005-12-16 14:37:42 得分 0
ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyTop




