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 9116857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:46:23+00:00 2026-06-17T04:46:23+00:00

putchar(char) writes a character to standard output and is normally provided by stdio.h .

  • 0

putchar(char) writes a character to standard output and is normally provided by stdio.h.

How do I write a character to standard output without using stdio.h or any other standard library file (that is: no #include:s allowed)?

Or phrased different, how do I implement my own putchar(char) with zero #include statements?

This is what I want to achieve:

/* NOTE: No #include:s allowed! :-) */ 

void putchar(char c) {
  /*
   * Correct answer to this question == Code that implements putchar(char).
   * Please note: no #include:s allowed. Not even a single one :-)
   */
}

int main() {
  putchar('H');
  putchar('i');
  putchar('!');
  putchar('\n');
  return 0;
}

Clarifications:

  • Please note: No #include:s allowed. Not even a single one 🙂
  • The solution does not have to be portable (inline assembler is hence OK), but it must compile with gcc under MacOS X.

Definition of correct answer:

  • A working putchar(char c) function. Nothing more, nothing less 🙂
  • 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-06-17T04:46:24+00:00Added an answer on June 17, 2026 at 4:46 am
    void putchar(char c) {
      extern long write(int, const char *, unsigned long);
      (void) write(1, &c, 1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If for example I should not use standard library functions like printf() , putchar()
Consider the following code: #include <stdio.h> int aaa(char *f, ...) { putchar(*f); return 0;
when i try char bla[32] = foobar; int i; putchar(bla[i]); with strlen(bla) < i
Here is my code!(sorry for my poor english) #include<stdio.h> int convert(char ch); int main(void)
I'm trying to write custom printf function. void debug_print(const char *fmt, ...) { const
I would like to write a function such as putchar , with the help
#include <stdio.h> #define OPT //define for assembly int main() { char chr; for(chr =
#include <stdio.h> #include <stdlib.h> #include <stdarg.h> void minprintf(char *fmt, ...) { va_list ap; char
#include <stdio.h> void reverse( const char * const sPtr ); int main ( void
#include <stdio.h> main(argc, argv) int argc; char *argv[]; { register int i, nflg; nflg

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.