I have a problem when I run codecrafters test
I get this error
[tester::#MG5] Running tests for Stage #MG5 (The type builtin: executable files)
[tester::#MG5] [setup] export PATH=/tmp/bar:$PATH
[tester::#MG5] [setup] export PATH=/tmp/foo:$PATH
[tester::#MG5] [setup] Available executables:
[tester::#MG5] [setup] - my_exe
[tester::#MG5] Running ./your_program.sh
[tester::#MG5] Expected prompt ("$ ") but received ""
[tester::#MG5] Assertion failed.
[tester::#MG5] Test failed
and it’s working fine on my pc, i don’t know where is the problem and I print the prompt at the beginning of the code
// extract environment paths
char *fullPaths = getenv("PATH");
pathCounter = extractPaths(fullPaths, environmentPaths);
while(1) {
// Uncomment this block to pass the first stage
printf("$ ");
// Wait for user input
fgets(input, sizeof(input), stdin);
...
Hey @MostafaEdrees11, could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.
Hey @andy1li
This is the link for the repository
@MostafaEdrees11 I added a few logs:
Notice that the after loop
flag is never printed:
This means the code is stuck inside the loop and never exits.
Since the outer loop is straightforward enough, the issue must stem from the inner loop:
Turns out the inner loop needs an out-of-bounds check as well to avoid running indefinitely.
Let me know if you’d like further clarification!
1 Like
Thank you @andy1li very much 
, It’s works
The problem in the infinite loop as you mentioned
1 Like
system
Closed
9
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.