[Solved] C# get position of a character from string

string aS = “ABCDEFGHI”; char ch=”C”; int idx = aS.IndexOf(ch); MessageBox.Show(string.Format(“{0} is in position {1} and between {2} and {3}”, ch.ToString(), idx + 1, aS[idx – 1], aS[idx + 1])); This wont handle if your character is at position zero and some other conditions, you’ll have to figure them out. 2 solved C# get position … Read more

[Solved] How do I select the first, second, or third digit from a String containing three digits? [closed]

You could try this. String nbr = input.nextLine(); int a=nbr.charAt(0)-‘0’; int b=nbr.charAt(1)-‘0’; int c=nbr.charAt(2)-‘0’; Also, you could use substring and parse the result Using Integer.parseInt int a=Integer.parseInt(nbr.substring(0,1)); //Contains the leftmost digit 2 solved How do I select the first, second, or third digit from a String containing three digits? [closed]

[Solved] returning string in C function [closed]

The idea is not that bad, the main errors are the mix-up of numerical digits and characters as shown in the comments. Also: if you use dynamic memory, than use dynamic memory. If you only want to use a fixed small amount you should use the stack instead, e.g.: c[100], but that came up in … Read more

[Solved] isnt everything where it should be, why the segmentation fault?

Here char *firstName[50]; firstName is array of 50 character pointer, and if you want to store anything into each of these char pointer, you need to allocate memory for them. For e.g for (int counter = 0; counter < 10; counter ++) { firstName[counter] = malloc(SIZE_FIRST); /* memory allocated for firstName[counter], now you can store … Read more