character-arrays

Trimming a string using an array of characters using C#

When you use the Trim() method on a string object, you can pass an array of characters to it and it will remove those characters from your string, e.g: string strDOB = "1975-12-23 "; MessageBox.Show(strDOB.Substring(2).Trim("- ".ToCharArray())); This results is "75-12-23" instead of the expected result: "751223", why is this? Bon...

Can I do a multidimensional char array in c++?

First off, this is a "homework" question so vector libraries and string libraries are off limits. I'm trying to get to the basics of c++. My intention with this code is to make and use an array of string arrays. A list of words in other words. When I run this code I get a bunch of nonsense. If there is a better way to make a list of w...

Please explain this behavior with character arrays/strings in C

I get this when I was trying something (just for understanding). Please explain this behavior: First attempt: void main() { char src[] = "vinay"; int i; // char name[5] = "test"; char *name= "abcde"; printf("%s \n", name); if (*(name+5) == '\0') printf("6th char is null\n"); strcpy(name,src...

Comparing character arrays and string literals in C++

I have a character array and I'm trying to figure out if it matches a string literal, for example: char value[] = "yes"; if(value == "yes") { \\ code block } else { \\ code block } This resulted in the following error: comparison with string literal results in unspecified behaviour. I also tried something like: char value[] = "...

Convert image data to character array

I'm building a mobile advertising sdk for the iPhone and I assume that the only way to store the images that will represent the button icons for the landing page controller [in the library] is to convert the images into character arrays. When I have the character array defined inline like: const char backButtonData[] = { 0x00, 0x01, 0x...

NULLs in string array

How to remove Null values in string array Like { ,-2,3, ,-4,+5, ,66...} I need to remove those null values in between and re-size the array I don't want to use lists I don't want to create a new array Please let me know if it is possible with simple code. Thank You. ...

Create files from file names in another file C++

Hi, I am working on sorting several large files in C++. I have a text file containing the names of all the input files, one on each line. I would like to read the file names in one at a time, store them in an array, and then create a file with each of those names. Right now, I am using fopen and fread, which require character arrays (I ...

string manipulating in C?

I want to print an array of characters, these characters are underscores first. Then the user can write characters on these underscores.I used gotoxy() but it doesn't work properly. That is what i wrote: int main(void) { char arr[20]; int i; char ch; clrscr(); for(i=0;i<=20;i++) { textattr(0x07); ...

How to remove a character from a string using baskspace in C?

can you give me an example of deleting characters from an array of characters in c? I tried too much, but i didn't reach to what i want That is what i did: int i; if(c<max && c>start) // c is the current index, start == 0 as the index of the start, //max is the size of the array { i = c; ...