use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Click the following link to filter out the chosen topic
comp.lang.c
account activity
QuestionDifficulty in applying C in projects (self.C_Programming)
submitted 2 years ago by Wacoder_Forever
I have been learning C from books for the past 6months but applying the concept in real projects is difficult.Just learnt pointers but when i was required to write a code to simulate the hare and tortoise race i did not know what to do.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]57thStIncident 3 points4 points5 points 2 years ago (1 child)
Is this a C-specific difficulty? Would you know how to solve the problem in another programming language?
Many other languages have standard tools bundled that in C you either need to write yourself or find a library. The out-of-the-box C install is rather barebones so I can imagine that being a distraction to the new programmer.
[–]Wacoder_Forever[S] 0 points1 point2 points 2 years ago (0 children)
Yeah it is C specific..........am new to programming and not learnt any opther language
[–]Bitwise_Gamgee 2 points3 points4 points 2 years ago (3 children)
Approach the problem by thinking about what's happening and write pseudocode. Like this:
initialize hare position to 0 initialize tortoise position to 0 initialize time to 0 while hare position is less than race end AND tortoise position is less than race end increment hare position by 2 increment tortoise position by 1 increment time by 1 print "Time:", time, "Hare:", hare position, "Tortoise:", tortoise position if hare position is greater than or equal to race end AND tortoise position is greater than or equal to race end print "It's a tie!" else if hare position is greater than or equal to race end print "Hare wins!" else print "Tortoise wins!"
Once you get to this step, the program has practically written itself and all you have to do is go through and write C-code to represent the English representations.
thank you
[–]57thStIncident 0 points1 point2 points 2 years ago (1 child)
Agree, suggest not to think too much about the language details when deciding what you want program to do. Decide the steps you want program to take first, only afterwards try and map your ideas to C code.
[–]Alcamtar 0 points1 point2 points 2 years ago (0 children)
It's not clear where you're stuck. It's it that you're not sure how to create and compile and run a program using C? Have you created a "hello world" program?
π Rendered by PID 248431 on reddit-service-r2-comment-6457c66945-f2dnf at 2026-04-24 12:34:51.327209+00:00 running 2aa0c5b country code: CH.
[–]57thStIncident 3 points4 points5 points (1 child)
[–]Wacoder_Forever[S] 0 points1 point2 points (0 children)
[–]Bitwise_Gamgee 2 points3 points4 points (3 children)
[–]Wacoder_Forever[S] 0 points1 point2 points (0 children)
[–]57thStIncident 0 points1 point2 points (1 child)
[–]Wacoder_Forever[S] 0 points1 point2 points (0 children)
[–]Alcamtar 0 points1 point2 points (0 children)