1

I wrote the following :

#include <cs50.h>
#include <stdio.h>

int main(void)

{
   //ask for name
   string name = get_string("What is your name?\n");

   // print hello, name
   printf("hello, %s\n", name);
}

And it runs, but when I check it with check50, I get the following error:

:( hello.c compiles.
    expected exit code 0, not 1

What do I do wrong?

Thanks in advance.

--> Found what I did wrong.. I submitted it without cs50/2019/x

1
  • Just to avoid any confusion, could you please edit your question and add the exact line of how you call check50 or submit50?
    – Blauelf
    Apr 9 '19 at 21:52
2

Your code passes the tests of cs50/2019/x/hello for me, so you probably did something wrong with the submission itself. A few things to check.

  1. Is this code saved as hello.c? Hello.c would be a different file.
  2. Is this code saved in the current directory? Likely not as much an issue in the lab environment. For example, if you type cat hello.c in the terminal, does it show this particular code?
  3. Have you maybe made any changes to the code, between compilation and submitting?

Another way to check what has been submitted would be to browse your GitHub repository. You'd find the submission at https://github.com/submit50/USERNAME/tree/cs50/2019/x/hello (replace USERNAME with your GitHub user), or check50 instead of submit50 if you used that tool. And do you see the slug cs50/2019/x/hello there? It's the git branch under which the file got submitted.

edit: And the /tree/cs50/2019/x/hello URL is same as selecting the cs50/2019/x/hello branch in the branch drop-down, which might already be the default in your case, I don't know GitHub enough to know all of its "magic". So you might see same content under both URLs, check the selected branch.

Could also be the submission process is temporarily bugged, which can happen, but usually with different symptoms.

1

Yes:

~/workspace/Pset1/ $ cat hello.c

#include <cs50.h>
#include <stdio.h>

int main(void)

{
   //ask for name
   string name = get_string("What is your name?\n");

   // print hello, name
   printf("hello, %s\n", name);
}

~/workspace/Pset1/ $

When I do check50 hello I get the following error:

Preparing............
Uploading...........
Checking......
:) hello.c exists.
:( hello.c compiles.
    expected exit code 0, not 1
:| prints "hello, world\n"
    can't check until a frown turns upside down

But I see that it's not submitted in /cs50/2019/x/hello but just in USERNAME (mine :) ). I'll look at that tomorrow further. thanks for trying to help!

2
  • Please do not use the answer space to edit your question.
    – MARS
    Apr 9 '19 at 19:35
  • Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question. - From Review
    – Cliff B
    Apr 10 '19 at 0:42
0

You should check for:

  • Name (is the name correct)

  • If the program runs at all

  • If you used the right command (check50 cs50/2019/x/hello (you could copy this), then submit50 cs50/2019/x/hello (you could copy this too))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .