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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:44:02+00:00 2026-05-24T13:44:02+00:00

What does char buf[MAXDATASIZE] = { 0 }; ‘s {0} means? tried to print

  • 0

What does char buf[MAXDATASIZE] = { 0 };‘s {0} means?

tried to print it out but it print nothing.

#include <stdio.h>

int main(void)
{
        char buf[100] = { 0 };
        printf("%s",buf);
        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-05-24T13:44:03+00:00Added an answer on May 24, 2026 at 1:44 pm

    This is just an initializer list for an array. So it’s very like the normal syntax:

    char buf[5] = { 1, 2, 3, 4, 5 };
    

    However, the C standard states that if you don’t provide enough elements in your initializer list, it will default-initialize the rest of them. So in your code, all elements of buf will end up initialized to 0.

    printf doesn’t display anything because buf is effectively a zero-length string.

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

Sidebar

Related Questions

#include <stdio.h> #define MAXLEN 256 int main() { int n; char buf[MAXLEN]; while((n =
#include <stdio.h> double seed=0.579832467; main(ac, av) int ac; char *av[]; { /* declare variables
Let's consider this simple test program: #include <stdio.h> #include <string.h> int main(int argc, char
Why does the following code seg fault before returning: int main() { char iD[20];
const int t=5; char buf[t+5]; When I compile this gives error in C but
I have the following test application: #include <stdlib.h> #include <string.h> #include <stdio.h> int main(void){
For example: sizeof(char*) returns 4. As does int* , long long* , everything that
class MyString{ char buf[100]; int len; boolean append(MyString str){ int k; if(this.len + str.len>100){
char ParseCmd(char *buf,int len) { char *p; p = strtok(buf, ); return *p; }
Basically the function I am exploiting is this: int getbufn() { char buf[512]; Gets(buf);

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.