sorry to hear that you're having so much trouble getting started. Let me open by saying the obvious. Go back and reread everything, watch the videos, and read the reading material suggested in the problem sets. BUT, think about it in parts - how to implement a printf() command, loops, etc. and think about how you can use them.
Next (especially at this stage), programming is about breaking problems down into as small a chunk or step as you can. Worry about doing one small task at a time. Again, as you try to implement each technique or tool, go back and review the material for that item, such as a printf, or a while loop.
To get you started, I'll give you an example of how I would think about it. This is only partial code, it doesn't include the main
block or all the #includes that a full program would have. It is just code snipets to get you thinking. I don't want to complicate things. So, let's begin.
Let's say you wanted to write a routine to print a certain number of #'s. The first thing is that I want to do is to print out a hash mark. That code is:
printf("#");
Easy enough. It prints a single hash. No linefeed, nothing else. Now, I want to do it, let's say, 5 times. What tool helps me do that? Answer: a FOR loop! So, let's wrap the printf with one.
for(int i = 0; i < 5; i++)
{
printf("#");
}
This will print out 5 consecutive hashes, #####
Also, since I think I have a fully functional block of code, I'll compile and run it to verify that it works. Once I've fixed all my syntax errors and am confident I haven't introduced any bugs or logic errors, I now want to think about making this more generic, so it will handle any number of hashes. Time to introduce a variable into the mix.
Also, while I'm at it, everything is printed on one line. Time to put in a line feed too.
int hashes = 5; // create the var and initialize to 5 for testing.
// replace 5 with hashes to make the loop generic for any number of hashes.
for(int i = 0; i < hashes; i++)
{
printf("#");
}
// add a line feed
printf("\n");
So now, I have a loop that will print any number of hashes followed by a line feed. This is the thinking I follow when writing a program.
Another tip. If you're having a problem with something in the actual program that you're working on, sometimes it helps to create a separate, small program to test only the small piece that you're working on. That way, you leave the work that you have created so far alone, while you can rewrite, break, and fix the small test prog that you're playing with. Once you get it working, you can migrate the code to the main program and get it working there.
BIG TIP: DO NOT TRY TO WRITE THE WHOLE PROGRAM AT ONCE!
Write it in small, logical blocks, and then compile the program and test that each section of code is working correctly before starting the next small block. Trying to write too much at once, especially when you're first learning, can introduce too many errors for you to easily find and fix and you'll get frustrated.
Finally, take advantage of the discussion forums, like reddit or CS50x Slack (referenced in course web page under discussion tab.) There are usually people around, especially on Slack, that can answer questions, often in real time.
Does this help? ;-) If not, add your questions in comments.
IF it does, please mark this question as answered. Let's keep up on forum housekeeping.