We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Thank you. I'm please to know that it helped you.
Thank you so much, this is the best tutorial I found about manipulating strings in C. Nice one
Can some one please help me, How to add array of string arrays in c programming
Hi there,
When I declared & initialized this array:
char palos[NUM_PALOS][MAX_LONG_PALOS] =
{
"oros",
"copas",
"espadas",
"bastos"
};
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,
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".
i want to get following string from user, how to do that
char arr[NUMBER_OF_STRING][MAX_STRING_SIZE] =
{ "array of c string",
"is fun to use",
"make sure to properly",
"tell the array size"
};
and then want to print the same
Hello,
I am searching for the solution to extract pertecular string from the given string
$PMTK011,MTKGPS*08
$PMTK010,001*2E
$PMTK011,MTKGPS*08
$PMTK010,002*2D
$GPRMC,064512.498,V,,,,,0.00,0.00,270121,,,N*4B
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGGA,064512.498,,,,,0,0,,,M,,M,,*49
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GLGSV,1,1,00*65
$GPGLL,,,,,064512.498,V,N*7B
$GPTXT,01,01,02,ANTSTATUS=OPEN*2B
I want to extract
$GPRMC,064512.498,V,,,,,0.00,0.00,270121,,,N*4B
Please help me out
sscanf
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.
how to store result in new variable instead of print?
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.
these tutorials are still much better than many other similar websites or youtube channel
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
Good tutorial with proper example
Thanks
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
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.
hmm, thanks for the info
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?
It sounds as though strchr() would do that.
how to split Audi@9.8 as car nmae and its mielage and store it seperately
You need to use strtok with '@' character, then use strcpy to copy the tokenized string to another string.
how to split Audi@10.8 as car name and mielage and store seperately
Please check my previous answer.
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?
use string array
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 ?
this expression helped me. Thanks a lot. Greetings from Turkey