Sujet : Re: Suggested method for returning a string from a C program?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 19. Mar 2025, 04:26:27
Autres entêtes
Organisation : None to speak of
Message-ID : <87a59hvgyk.fsf@nosuchdomain.example.com>
References : 1
User-Agent : Gnus/5.13 (Gnus v5.13)
DFS <
nospam@dfs.com> writes:
I'm doing these algorithm problems at
https://cses.fi/problemset/list/
>
For instance: Weird Algorithm
https://cses.fi/problemset/task/1068
>
My code works fine locally (prints the correct solution to the
console), but when I submit the .c file the auto-tester flags it with
'runtime error' and says the output is empty.
>
------------------------------------------------------------
// If n is even, divide it by two.
// If n is odd, multiply it by three and add one.
// Repeat until n is one.
// n = 3: output is 3 10 5 16 8 4 2 1
>
>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
>
int main(int argc, char *argv[])
{
int n = atoi(argv[1]);
[...]
There's your problem.
https://cses.fi/problemset/text/2433"In all problems you should read input from standard input and write
output to standard output."
The autotester expects your program to read arguments from stdin, not
from command line arguments.
It probably passes no arguments to your program, so argv[1] is a null
pointer. It's likely your program compiles (assuming the NBSP
characters were added during posting) and crashes at runtime, producing
no output.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */