char additional_part()
{
/* ifstream */
ifstream textfile;
textfile.open("ignore.txt");
textfile >> noskipws;
int row = cal_row_ignore_file(); // row = 7
char **ig_word = new char *[row]; // setting up two-dimensional arrays
for (int i = 0; i < row; i++)
{
ig_word[i] = new char[51];
}
for (int i = 0; i < row; i++) // read file contents
{
textfile.getline(ig_word[i], 51, '\n');
}
textfile.close();
/* process */
int w_len[row];
for (int i = 0; i < row; i++)
{
w_len[i] = strlen(ig_word[i]);
}
for (int i = 0; i < row; i++)
{
*ig_word[i] = *u2l(ig_word[i], w_len[i]); // uppercase to lowercase
}
for (int i = 0; i < row; i++)
{
delete[] ig_word[i];
}
delete[] ig_word;
return **ig_word;
}
int main()
{
// data();
char **ig_word = new char *[7]; // setting up two-dimensional arrays
for (int i = 0; i < 7; i++)
{
ig_word[i] = new char[51];
}
**ig_word = additional_part();
for (int i = 0; i < 7; i++)
{
cout << ig_word[i] << endl;
}
return 0;
}
我想做一个二维数组的指针传递,但是在main函数中,接收时英文单词变乱码了,想知道问题原因