frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

I wrote my first C project after a long time. Unix wc clone. NO AI

https://github.com/emanueleoggiano/word_count
4•emanueleoggiano•55m ago

Comments

emanueleoggiano•55m ago
Hello everybody, I am writing this post because I've just finished my first C project after a long time. It is a clone of the UNIX wc (Word Count). Right now, the program can only compute the number of words and rows. I haven't implemented the flags like -l, -w etc that wc has. Feel free to give me tips on how to write better C code and to become a better programmer
kooi•23m ago
Seems pretty good.

When I was at NASA, their C coding required everything to be explicit. So

`if(!w_cnt || !r_cnt) return NULL_PTR; `

was wrapped in real brackets.

I was also told not to use ternery operators. But that's NASA specific things.

Another NASA specific thing was to declare all variables at the top of a function instead of scattering declarations throughout. I see you've put them after the argument checks, so actually I think that lives up to that spirit.

ButlerianJihad•6m ago
I suppose that you mean wrapping in curly-braces, for explicit syntax?

  if (cond) {
    return val;
  }
Also, there is only one instance of ternary operator in ANSI C:

  cond ? succ() : fail();
This ternary syntax does not appear in main.c

"NULL_PTR" is a rather bold choice for an integer error status. I see where it’s coming from. It’s not wrong, but there are conventions for naming things.

Unix exit value 0 should indicate success. Posix system calls always return 0 on success. ANSI C library calls as well. For user-defined functions, you don’t have access to the "errno" variable, so you do what you gotta do.

Speaking of exit values, it’s also a good convention to explicitly use "exit()" rather than "return()" from main(). It’s exactly the same result. I recommend a book on standard C programming. I haven’t seen any for 30 years.

kooi•21m ago
Also, for some reason the "standard" in C return values is 0 for success.
kooi•18m ago
Personally, I'd make the NULL_PTR error message a bit more specific. "Memory Error" is quite general. The real issue is that specific invalid arguments were passed in.

Now since this may live in it's own module and not be a public function, that could be fine. But if it's ever expanded, you'll want callers to know what specifically went wrong to help debugging.

State Department Wants Palantir's Advice on Free Speech

https://theintercept.com/2026/08/07/state-department-palantir-free-speech-surveillance/
1•cdrnsf•1m ago•0 comments

U.S. Intel Finds Putin Could Test NATO's Resolve with Limited Incursion

https://www.wsj.com/world/europe/u-s-intel-finds-putin-could-test-natos-resolve-with-limited-incu...
1•cwwc•3m ago•0 comments

Show HN: Agent Monitor – Monitor Your Coding Agent Live

https://agent-monitor.ai/
1•gsibble•5m ago•0 comments

Tlbic v10.1 French Supplement: A local basic income model for systemic despair

https://drive.google.com/file/d/1MGFLYnYyVzWV_H4NsAKc1_yA_dToxzUz/view?usp=drive_link
1•michikawa59•5m ago•1 comments

This Mine Predicts Major Wars. It's Opening Again

https://www.bloomberg.com/graphics/2026-opinion-australia-tungsten-mine-us-war-defense-china/
1•mooreds•5m ago•0 comments

Ask HN: Are You Preparing for the Singularity

1•blululu•6m ago•1 comments

Size the Orbs of Production

https://ampcode.com/news/size-the-orbs-of-production
1•tosh•7m ago•0 comments

India Test-Fires 4,000KM Agni-4 Nuclear Missile

https://defencesecurityasia.com/en/india-agni-4-nuclear-missile-test-china-indo-pacific/
1•Teever•7m ago•0 comments

Hand-coding will never die

https://christinacodes.dev/writing/hand-coding-will-never-die/
1•vinhnx•7m ago•0 comments

Engineering Culture Trends 2026 – Food for Agile Thought #556

https://age-of-product.com/food-agile-thought-556-engineering-culture-trends-2026/
1•swolpers•8m ago•0 comments

Show HN: Infinite scrolling comes to Hazumi for Hacker News

https://apps.apple.com/us/app/hazumi-for-hacker-news/id1670237209
1•jrhey•9m ago•0 comments

The Life and Times of Maxis, Part 3: The Sims

https://www.filfre.net/2026/08/the-life-and-times-of-maxis-part-3-the-sims/
1•doppp•10m ago•0 comments

Most explanations fail for the same reason

https://tryclicked.app/blog/most-explanations-fail
1•sagunbuilds•10m ago•0 comments

Show HN: MCP-debug-proxy – A visual reverse proxy for MCP and OAuth traffic

https://github.com/ytkoka/mcp-debug-proxy
1•ytkoka•11m ago•0 comments

Chinese Model Kimi K3 Breaks UK AI Safety Institute Benchmark Evaluations

https://blog.frontier.security/chinese-model-kimi-k3-breaks-uk-ai-safety-institute-benchmark-eval...
1•akyuu•11m ago•0 comments

Ask HN: AI4 Conference, Thoughts?

1•joshcsimmons•11m ago•0 comments

Who Supervises the Supervisor? A Riff on Machine Learning

https://johnhorgan.org/cross-check/who-supervises-the-supervisor-a-riff-on-machine-learning
2•lschueller•11m ago•0 comments

Code review bottlenecks: How we hill climbed our way to higher PR throughput

https://www.assembled.com/blog/code-review-bottlenecks-how-we-hill-climbed-our-way-to-higher-pr-t...
8•johnjwang•12m ago•0 comments

University celebrates Baby's 65th birthday (2013)

https://www.manchester.ac.uk/about/news/university-celebrates-babys-65th-birthday/
1•Bluestein•13m ago•0 comments

The Suicide Crisis in Wyoming

https://www.nytimes.com/2026/08/04/opinion/suicide-wyoming-mental-health.html
1•mooreds•15m ago•0 comments

The secret nuclear material the US forgot how to make

https://en.wikipedia.org/wiki/Fogbank
3•historical1234•15m ago•1 comments

AI agents fake identities, target real people in new security incident

https://www.cnn.com/2026/08/04/tech/ai-anthropic-openai-security-breach-intl-hnk
3•mooreds•16m ago•0 comments

Parasol Lost

https://actuaries.org.uk/news-and-media-releases/news-articles/2026/jan/14-jan-26-parasol-lost-re...
1•simonebrunozzi•16m ago•0 comments

Slime Without Plugins Using Kitty

https://lee-phillips.org/kittyslime/
2•leephillips•17m ago•0 comments

Manchester Statistical Society was founded in 1833

https://collection.sciencemuseumgroup.org.uk/people/ap12481/manchester-statistical-society
1•Bluestein•18m ago•0 comments

Let Over Lambda is free online to read as pdf

https://letoverlambda.com/lol.pdf
1•artsi0m•18m ago•3 comments

Finland to stop maintaining poles carrying communication lines with Russia

https://meduza.io/en/news/2026/07/29/finland-to-stop-maintaining-poles-carrying-communication-lin...
2•Sami_Lehtinen•18m ago•0 comments

Show HN: Back end Engineer – Visual guides for system design and cloud infra

https://www.backendengineer.in
1•pvtsparsshh•19m ago•0 comments

Zohran Mamdani's NYC Tech Team Is What DOGE Should Have Been

https://www.wired.com/story/mamdani-assembles-his-nyc-tech-team/
4•gorbachev•20m ago•1 comments

Ask HN: Why aren't there more Operating System startups?

1•senor_digimon•21m ago•1 comments