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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:37:34+00:00 2026-06-01T18:37:34+00:00

How to declare array of strings in C. Is it like char str[100][100] ={this,that,those};

  • 0

How to declare array of strings in C.
Is it like

char str[100][100] ={"this","that","those"};

If so how to access the values .. can i travers like this?
(It does not give any compilation error ..but shows some additional garbage characters)

int i ,j;
char  c[100][100] = {"this","that"};
for(i = 0 ;c[i] != '\0';++i)
 for(j = 0; c[i][j] != '\0';++j)
   printf("%c",c[i][j]);

Is it necessary to add ‘\0’ at end of eac string..for ex:

 char c[100][100]={"this\0","that\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-01T18:37:35+00:00Added an answer on June 1, 2026 at 6:37 pm

    How to declare array of strings in C

    It is Ok, but you will have to be extremely careful of buffer-overflow when dealing with these strings

    can i travers like this?

    Note that the condition in the first for loop: for(i = 0 ;c[i] != '\0';++i) is probably wrong, and will fail since c[i] is an array, whose address is not 0. You should probably iterate the outer array by numbers [until you read all elements], and not until you find some specific character. You can do that by maintaining a different variable n, which will indicate how many elements does the array currently have.

    Is it necessary to add ‘\0’ at end of eac string..for ex:

    No – the compiler add it to you, it is just fine without adding the '\0' to the string.

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

Sidebar

Related Questions

I have a program which declares an array of strings like this: char *colors[4]
I know I can declare an array of string in XAML like this: <x:Array
This is a followup to Multi-dimensional char array (array of strings) in python ctypes
I have a big array with many strings like this: $langArr = array( 'welcome'
I know that when passing strings between functions char *str is almost the same
Im trying to declare an array in C++ but i keep getting this error.
I need to declare an array of pointers to functions like so: extern void
I need to declare 3d array variable but can't. int[][][] ary = new int[5][2][];
I have declared a DLL import in my C# program that looks like this:
Say I have declared a 2d array like char* array[30][30]; and what I am

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.