No, they’re the same, in C or C++.
But they are statements of array in C, already in C++ it should be completely different. If it really will port to C++ it has to change everything. Otherwise you will be programming in C in the C compiler++.
I have no idea why the person made a sum and did not put the value 5 right away. You can speculate, as they did here, but they’re all nonsense (only the person who did it can explain, and maybe not even she, often people do things they don’t understand). He may have even confused it with terminator, but in this case it doesn’t even make sense, because the array is 5 pointers to texts that will have the terminator, not even the size of them.
You could do it:
array<string, 5> matches;
But most people will take it and do it:
vector<string> matches;
I put in the Github for future reference.
In most cases it is as or more appropriate.
You can do as in the original, it works, but know that it’s not porting to C++, it’s two very different languages, the issue is that the C++ compiler compiles almost all C codes, so people think it’s the same thing, if you want to port to C++ the above codes are the most likely candidates.
See more in Difference between Std::list, Std::vector and Std:array.
If you’re going to behave properly, you have to change almost everything like @Maniero said. Char arrays as it is in this section hardly makes sense in c++ when you can use
std::string
. The reason for being 4+1 and not 5 is because you want to give the idea that there are 4 chars plus the terminator, and so it is clearer in terms of reading the code.– Isac