Skip to main content
Code Review

Return to Revisions

2 of 2
replaced http://stackoverflow.com/ with https://stackoverflow.com/

I few items that I didn't see mentioned yet:

  • You have an unused variable named arr.

  • Your format specifies the type char *, but your argument has type char (*)[16]

while(scanf("%s", &plate) == 1) {

To fix it, remove the &.

  • All you do in this loop is print a string, with no formatting.
for(int i = 0; i < n; i++)
 printf("%s\n", plates[i]);

Use puts() when you are only printing the string and not formatting it. As a bonus, you don't have to remember the newline (\n) character.

 for(int i = 0; i < n; i++) puts(plates[i]);
  • I am led to believe that you might be compiling your code as code.
char** aux = (char**)malloc(length * string_size);

Yes, it might be valid, but that line right there would be unacceptable when compiling as C code. You shouldn't be doing that.

Here is a very long list of the incompatibilities between ISO C and ISO C++. Those are the reasons you compile C code, as C code.

If I happen to be wrong in my assumption that you are compiling C code as C++ code, you still should not be casting the results of malloc().

syb0rg
  • 21.9k
  • 10
  • 113
  • 192
default

AltStyle によって変換されたページ (->オリジナル) /