问题描述
- 大神帮我看这个pig latin C++程序问题报debug assertion failed
-
#include
#include
using namespace std;
const int SIZE = 80;
void printLatinWord( char const *const );
int main()
{
char sentence[SIZE], *tokenPtr;
cout << "Enter a sentence:n";
cin.getline( sentence, SIZE );cout << "nThe sentence in Pig Latin is:n";
tokenPtr= strtok_s( sentence, " " ,NULL);while ( tokenPtr!=NULL ) {
printLatinWord( tokenPtr );
tokenPtr = strtok_s( NULL, " ",NULL );
//if ( tokenPtr )
cout << ' ';
}
cout << '.' << endl;
return 0;
}void printLatinWord( char const * const wordPtr )
{
int len = strlen( wordPtr );
for (int i = 1; i < len; ++i )
cout << *( wordPtr + i );
cout << *wordPtr << "ay";
}
时间: 2024-10-30 20:20:54