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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:21:56+00:00 2026-05-15T04:21:56+00:00

gcc 4.4.4 c89 I was just experimenting with a int array. And something just

  • 0

gcc 4.4.4 c89

I was just experimenting with a int array. And something just came to my mind. Can I nul terminate it. For example, I am using a 0 to nul terminate. However, 0 could well be a valid value in this array.

The code below will terminate after the 5. Even though I mean 0 to be a valid number. However, I could specify the size of the array. But in this case, I don’t want to this as I am just interested in this particular problem.

Many thanks for any advice,

#include <stdio.h>

static void test(int *p);

int main(void)
{
    int arr[] = {30, 450, 14, 5, 0, 10, '\0'};

    test(arr);

    return 0;
}

static void test(int *p)
{
    while(*p) {
        printf("Array values [ %d ]\n", *p++);
    }
}
  • 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-15T04:21:57+00:00Added an answer on May 15, 2026 at 4:21 am

    In short, no. Technically nul characters are equally valid in strings too, it’s just a convention that we use them for marking the end of a string, and all the standard library functions expect that. There are “double nul-terminated” strings that end in \0\0 for cases where a string needs to contain a \0, but then of course you have the problem of not being able to store \0\0 in the string.

    If you don’t want to store an array’s size separately (or use trickery like sizeof), you need to come up with a sentinel that can be stored in that type but you know won’t be part of the array; you could use 45 as long as you’re sure arr won’t have that as a valid value, it just needs to be unique

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

Sidebar

Related Questions

gcc 4.4.2 c89 I was just working on some pointers. However, with the program
gcc 4.4.3 c89 I have the following string sip:12387654345443222118765@xxx.xxx.xxx.xxx How can I extract just
gcc 4.4.3 c89 I am just getting started with log4c. However, there is very
Using gcc 4.4.3 c89: I am just working on the following code below: I
Using exuberant-ctags 5.8 for gcc 4.4.3 c89 I am just started using exuberant-ctags and
GCC compiles (using gcc --omit-frame-pointer -s ): int the_answer() { return 42; } into
gcc c89 I am came across this code. typedef __int32 int32_t; typedef unsigned __int32
gcc 4.4.4 C89 I am just wondering what most C programmers do when they
gcc 4.4.4 c89 I am just wondering is it worth passing a const into
gcc 4.4.4 c89 I am just wondering is there any standard that should be

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.