Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 911013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:07:57+00:00 2026-05-15T17:07:57+00:00

I have tried to implement the puts function.It in actual returns a value but

  • 0

I have tried to implement the puts function.It in actual returns a value but i cant get what should it return.please check my code and guide me further

/* implementation of puts function */
#include<stdio.h>
#include<conio.h>
void puts(string)
{
    int i;
    for(i=0;    ;i++)
    {
        if(string[i]=='\0')
        {
            printf("\n");
            break;
        }
        printf("%c",string[i]);

    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:07:57+00:00Added an answer on May 15, 2026 at 5:07 pm

    See comments in code.

    int puts(const char *string)
    {
        int i = 0;
       while(string[i])  //standard c idiom for looping through a null-terminated string
        {
            if( putchar(string[i]) == EOF)  //if we got the EOF value from writing the char
            { 
                return EOF;
            }
            i++;
        }
       if(putchar('\n') == EOF)  //this will occur right after we quit due to the null terminated character.
       {
           return EOF;
       }
       return 1; //to meet spec.
    }
    

    And, as an aside – I’ve written the equivalent of putc, puts several different times in relation to developing on embedded systems. So it’s not always just a learning exercise. 🙂

    Comment on EOF: It is a POSIX constant from stdio.h.
    In my Linux stdio.h, I have this definition:

    /* End of file character.
       Some things throughout the library rely on this being -1.  */
    #ifndef EOF
    # define EOF (-1)
    #endif
    

    That definition code is GPL 2.1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to implement css sticky footer on my page but it doesn't
I have tried to implement this jQuery active menu code: http://docs.jquery.com/Tutorials:Auto-Selecting_Navigation $(function(){ var path
I have tried to implement the google plus button into our site, but the
I have tried to implement other solutions but have had no luck... hoping someone
I have been looking around for solutions, and tried to implement what is often
I have tried searching over the internet about this problem but not able to
I have tried many permutations but they all don't seems to work well. Am
i have tried implement two methods recursive and dynamic method and both took 0
I have tried to implement the Head First Duck problem with Startegy. I am
I have tried to implement binary insertion sort algorithm. Here is my code: public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.