我希望代碼能夠搜索單詞中間句子,並查看它的第一個字母是小寫字母。與大寫和小寫相關的C++幫助
如果是這樣,那麼它就是大寫。例如:約翰討厭每天使用C++,它會將C++中的C改爲大寫。
下面是代碼
#include <iostream>
#include <string>
#include<cstdlib>
#include<fstream>
using namespace std;
ifstream in_stream;
ofstream out_stream;
int main()
{
in_stream.open("in.dat");
out_stream.open("out.dat");
char s[256];
in_stream>>s;
s[0] = tolower(s[0]);
out_stream<<s;
in_stream.close();
out_stream.close();
system("Pause");
return 0;
}
這是雁在這裏被 http://stackoverflow.com/questions/313970/how-to- convert-stdstring-to-lower-case – teivaz
爲什麼代碼中存在空白鏈接?沒有縮進?你爲什麼使用'char'數組? –
@teivaz沒有提及如何找到字符串的中間部分...但我確定這是一個不同的答案 –