Hot answers tagged

4

When you have completed the pset, and you have checked your program works correctly, using check50 you should go at the CS50 submit and upload the file you have written your code in, called the source code. There are very detailed steps at the end of each pset's specification.


2

You gotta change your directory to where cash.c is located. cd pset1


1

This is how to submit on edx, I would assume that if you are taking the class in any other capacity there is a similar link. http://apps.cs50.edx.org/cs50x/2015/@/portal


1

You seem to have made quite a few mistakes in your code. This is of course not unusual for someone who's just starting out, so let me point you in the right direction. You are reading the first reply into a string variable called s. Later on, you refer to it as hungry. Choose whichever you prefer and rename the other instance to the same. To assign a ...


1

easy. unzip filename.zip For more info, on a command line, just type unzip with no parameters.


1

These characters are used as "wildcards" or placeholders. They are used in conjunction with something like printf(). Very basic example //declaring an int variable to a value of 5 int x = 5; //printing "%i" using the value of X printf("%i", x); Result would print: 5 This is because printf is accepting 2 parameters here. When you ...


1

printf formatting is a language unto itself. This document helped me a lot. Hope you find it useful.


1

You cannot compare strings in C to compare strings you must use a function called strcmp()if I remember correctly it should be in the string.h so just #include <string.h> and you should be able to use it. If both strings are identical it should return 0, if not then the strings are not equal.


1

The problem lies here: for(int i = 0; i < keyL - 1; i++) { for(int j = i; j < keyL; j++) { if(key[i] == key[j]) return 0; } } When the loop runs the first time, it will always fail because i == j at the start. It's comparing the first letter in the key to itself. It should start with j = i+1. There may be other ...


1

You make a new file by clicking the green plus sign at the top, next to where it says the name of the file you are currently on. On your keyboard, then do command shift S. It will give you options for where to save the file and what the name should be. Name it pseudocode.txt and put it in your mario folder. If this helps, click the check mark or upvote it.


1

Just a guess, did you open a new file that has yet to be named or saved? Assuming you're in the CS50 IDE, are you writing your code in a file with the .c extension? The IDE has to see that extension to determine the file type and how to highlight stuff. If you just opened a new file and didn't save it to a .c file, it thinks it's a plain text file.


1

You did use an undeclared identifier j in the second for loop. It isn't created until and only inside the following 3rd for loop. The compiler never lies. It might mislead on occasion, but it never lies.


1

Local variables are not initialised by default. The values you find there are the remains of other variables (or data related to function calls) that occupied that exact same location of the stack previously, for example as part of a get_int or printf call. It's your responsibility to assign a value before you read it. Often that means to initialise the ...


1

if n >= 0: break This breaks you out of the While loop, so your program simply ends if the user gives you a positive number.


1

Taking the first one through the example in the spec: 3 7 1 4 4 9 6 3 5 3 9 8 4 3 1 Okay, let’s multiply each of the underlined bold digits by 2 7*2 + 4*2 + 9*2 + 3*2 + 3*2 + 8*2 + 3*2 That gives us: 14 + 8 + 18 + 6 + 6 + 16 + 6 Now let’s add those products' digits (i.e., not the products themselves) together: 1 + 4 + 8 + 1 + 8 + 6 + 6 + 1 + 6 + ...


1

Right now your code is just printing m, bottles is only defined, it is never called. If you want to declare a variable, but not initialize it, int b; is what you would write. int b = b; assigns a new variable (b) to the previous b, of which you have none. In "int bottles(int b)", you're saying you want a function ('bottles') who will take an argument ('b');...


1

The short answer is that you're using the wrong format code. While you can cast the values and make it work, it would be easier to just use the correct code, %lu, for an unsigned long. google printf format codes for more extensive info on the subject. If this answers your question, please click on the check mark to accept. Let's keep up on forum ...


1

It is because your Compiler warnings are ON. The return type of sizeof() function is size_t. It is System and Compiler dependant. May be if you Compiler your code on 32 bit machine, it will have difference results and on 64 bit different. According to the 1999 ISO C standard (C99), size_t is an unsigned integer type of at least 16 bit (see sections 7.17 ...


1

From your first link choose Index in the Source Code pane (far right). Choose misspellings/. Click on download to the right of speller. It will open with a text editor (like notepad++). It's also in the ZIP file.


1

The problem lies with your use if isalpha() and islower(). Your code is: if (isalpha(encryptString[i]) == true) Surprisingly unintuitively, if the character is an alpha, this will NOT evaluate as a true statement. If you read the documentation, it says that it returns 0 if false and a non-zero if true. This number varies, depending on the architecture, ...


1

Your loops mean that you don't print out the right number of # signs. Because your i starts of at 0, on the first pass j = 0 which equals i and so only one pass is printed. Therefore you need to change the initial value of i and your limit so that on each pass, 2, then 3, then 4 etc. # signs are printed instead of 1, then 2, then 3 etc.


1

Reference50.cs50.net may help you- a list of a lot of C functions, and the header files they are in.


Only top voted, non community-wiki answers of a minimum length are eligible