yamidkeen
yamidkeen

Reputation: 9

C++ about pointer used

int main()
{
   int rows=0;
   int studId,course;
   char ch;
while(FileIn>>studId>>course)
   {
   for(int i=0;i<5;i++)
   {
       FileIn>>ch;  
   }
   rows++;
}
char** questions = new char*[rows];

What is the meaning of new char*[rows]? if rows = 10.

The file content is

20 1 A B C D E 
20 1 A B C D E
20 1 A B C D E
20 1 A B C D E
20 1 A B C D E
20 1 A B C D E
20 1 A B C D E
20 1 A B C D E
20 1 A B C D E
20 1 A B C D E

Upvotes: 0

Views: 55

Answers (2)

kavitha J
kavitha J

Reputation: 11

since 'questions' is double pointer, it is made to point an array of pointers of size rows using new char*[rows] that is, after char** questions = new char*[rows];, questions can be made to point to pointers of type char. Hope I answered your question.

Upvotes: 0

alan23273850
alan23273850

Reputation: 262

Allocates an array of 10 elements of type "char*."

Upvotes: 1

Related Questions