We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. C
  3. Introduction
  4. "Hello World!" in C
  5. Discussions

"Hello World!" in C

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • lisag4243
    3 years ago+ 27 comments

    gets is deprecated for security reasons, because it can't protect against a buffer overflow. Man page says "Never use this function." fgets is recommended instead.

    So I used:

    int main ()
    {
    	char s[100];
    	fgets(s, sizeof(s), stdin);
    	printf("Hello, World!\n%s", s);
    	
    	return 0;
    }
    
    62|
    Permalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature