We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Mustafa Açık • 5 years ago

this expression helped me. Thanks a lot. Greetings from Turkey

Donotalo • 5 years ago

Thank you. I'm please to know that it helped you.

Yushu Jian • 2 years ago

Thank you so much, this is the best tutorial I found about manipulating strings in C. Nice one

Rajendra prasad reddy • 2 years ago

Can some one please help me, How to add array of string arrays in c programming

Abelardo León González • 3 years ago

Hi there,

When I declared & initialized this array:

and prints out the third position palos[2] should print "espadas" but "espadasbastos" is outputted. NUM_PALOS = 4 and MAX_LONG_PALOS = 7.
It happens on Ubunt 20.10 with C99 & CLion as IDE.

What's wrong?

Best regards,

Garimedes • 3 years ago

I assume MAX_LONG_PALOS has to be at least 8 in order to fit the NULL character at the end of "espadas". Otherwise the array will be stored in memory like this:
{ 'o', 'r', 'o', 's', '\0', 'c', 'o', 'p', 'a', 's', '\0', 'e', 's', 'p', 'a', 'd', 'a', 's', 'b', 'a', 's', 't', 'o', 's', '\0' }
and when you request palos[2], the compiler does not know to stop at the end of "espadas", but reads into the next array, resulting in "espadasbastos".

Vaibhav Hake • 3 years ago

i want to get following string from user, how to do that

{ "array of c string",
"is fun to use",
"make sure to properly",
"tell the array size"

and then want to print the same

Nishikant Hingole • 3 years ago

I am searching for the solution to extract pertecular string from the given string


I want to extract


Please help me out

Denis Dos Santos Silva • 2 years ago


Aqsa • 3 years ago

I have a file instead of string array and file contain lines i want to split comma separated words and using a loop which can automatically pass to the next line after the 1st line words completed.. kindly help me with this.

Philipe • 3 years ago

how to store result in new variable instead of print?

Peter • 4 years ago

Hi. There is a wrong basic assumption in this article. An array is not necessarily stored sequentially in memory. The first char can be stored in one memory location and the next in an entirely other location in memory, so you cannot simply advance the pointer by one.

upendra chaudhari • 4 years ago

these tutorials are still much better than many other similar websites or youtube channel

Gsb2 • 4 years ago

If I wanted to split a string using with char delim[] = "dr", is there any way that I can find out which character did was using to delimit every time it does that. For example, if the string is 40d50r30d.., is there any way that I could know that the 40 was delimited by the char d and the 50 was delimited by char r and likewise

Sunil Sheth • 4 years ago

Good tutorial with proper example

hopefor • 4 years ago

I m signed up for ask this,why i must use define ? When i create an integer variable and put into char arr[x][y] as x and y integers i get an error.I wonder why this cause to an error?And thanks for post by the way

Donotalo • 4 years ago

In C you can't declare arrays as char arr[x][y] where x and y are variables. The compiler must know the size of the array at compile time. So you must declare the size as constant.

hopefor • 4 years ago

hmm, thanks for the info

shivam panchbhai • 4 years ago

suppose there are two strings and i need to find if the 1st character of the 1st string is present in the 2nd string then how to write code for this?

PaulEmmons • 4 years ago

It sounds as though strchr() would do that.

Srinivasan1 • 5 years ago

how to split Audi@9.8 as car nmae and its mielage and store it seperately

Donotalo • 5 years ago

You need to use strtok with '@' character, then use strcpy to copy the tokenized string to another string.

srini • 5 years ago

how to split Audi@10.8 as car name and mielage and store seperately

Donotalo • 5 years ago

Please check my previous answer.

Anonymous • 5 years ago

hello thank you this help. here I am able to split token,
But can you help how can i store each part of token in different variable?

Vikas Gupta • 5 years ago

use string array

Anonymous • 2 years ago

hi iam trying for user id and password in command line interface
FORMAT: adduser <username> <password> <confirm password="">
how can i store and compare these parameters using strtok ?