Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions tests/C++/single_file.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
#!../../c -Wall -Werror -lm --
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
unsigned int i;

printf("argc=%d\n", argc);

int main(int argc, const char *argv[]) {
if (argc != 4) {
fputs("error: need 3 arguments\n", stderr);
return 1;
fprintf(stderr, "Usage: %s <arg1> <arg2> <arg3>\n", argv[0]);
return EXIT_FAILURE;
}

for (i = 0; i < 4; i++)
printf("argc = %d\n", argc);
for (size_t i = 0; i < (size_t)argc; i++) {
puts(argv[i]);
}

printf("%.0f\n", pow(2, 10));
double result = pow(2, 10);
if (result == 0 && 2 != 0) { // Simple check for pow failure, optional
fprintf(stderr, "Error computing power.\n");
return EXIT_FAILURE;
}
printf("%.0f\n", result);

return 123;
return EXIT_SUCCESS;
}