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

  • Home
  • SEARCH
  • 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 8513369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:32:49+00:00 2026-06-11T04:32:49+00:00

I’m basically trying to make this code work in windows and I have to

  • 0

I’m basically trying to make this code work in windows and I have to use the sprint() and writefile() functions included in the windows API. I’m a little confused as to how to go about this, the windows C code seems a lot more complicated.

#include <stdio.h>
#include <string.h>
//Defining String used for name//
#define NAME "Rodger Rodger"
Main(){
char tbuf[35];
memset(tbuf, '\b', sizeof(tbuf));
sprintf(&tbuf[0], "Hello %s\n", NAME);
write(1,tbuf,sizeof(tbuf));
}

Output: Hello Rodger Rodger

This works however I need to do it in Windows using the writefile() and sprint() functions.

EDIT: Managed to do it in the end. This is the final code:

//C Programming in Windows //
//Timothy Ford //
#include  <stdio.h>
#include <windows.h>


//Defining String used for name//
#define NAME "Timothy Ford"

int main(){
char tbuf[35];

//Handle used to define output
HANDLE Outta = GetStdHandle (STD_OUTPUT_HANDLE);

//DWORD used to store bytesWritten
DWORD written;

memset(tbuf, '\0', sizeof(tbuf));
sprintf(tbuf,"Hello %s\n", NAME);

//WriteFile used for output of string
WriteFile(Outta, tbuf, sizeof(tbuf), &written, NULL);


return 0;
}
  • 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-11T04:32:51+00:00Added an answer on June 11, 2026 at 4:32 am

    I notice several problems with your code:

    • Don’t pass the address of tbuf[0] to sprintf. Instead pass tbuf. Tbuf is already a pointer to character string: sprintf(tbuf, "Hello, %s\n", NAME);. Not that it will not work as is but I think the version I propose is both shorter and clearer.

    • Why are you memsetting tbuf to ‘\b’? This is backspace while I believe you want to set tbuf to 0(‘\0’)

    Here is the working version on ideone.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to loop through a bunch of documents I have to put

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.