C++字符数组问题
大佬们,我现在要给一个char类型的数组str里赋值,并且以句号结尾,该怎么写啊{:10_266:}我想用while循环写但是有问题。。。
char str;
cout<<"Please input a sentence:";
while(cin.get()!='.')
{
cout<<str<<endl;
} https://i.bmp.ovh/imgs/2020/11/6ee387d7e494d987.png
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
char str;
cout << "Please input a sentense:";
char ch;
int i = 0;
while ((str = cin.get()) != '.');
str = 0;
cout << str;
return 0;
}
页:
[1]