#include
#include
using namespace std;
int main()
{
string P = {'c','b'};
for (int i = 0;i<sizeof P;++i)
{
cout << P[i];
}
cout << "string is over";
}
新学C++,求问老铁们为什么报错“ string subscript out of range”?
该怎么改?
#include
#include
using namespace std;
int main()
{
string P = {'c','b'};
for (int i = 0;i<sizeof P;++i)
{
cout << P[i];
}
cout << "string is over";
}
新学C++,求问老铁们为什么报错“ string subscript out of range”?
该怎么改?
// Q765981.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
string P = "cb";
for (int i = 0;i< P.length();++i)
{
cout << P[i];
}
cout << "string is over";
}