[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

[Solved] Dynamic Char Allocation [closed]

You are not managing your buffers correctly, not even close. In fact, there are a LOT of mistakes in your code. Every one of your sizeof() calls is wrong. You are leaking buffer, tmp, and data on every loop iteration. You are using strcat() incorrectly. And worse, you are processing binary audio data using string … Read more

[Solved] C. for loop with chars

This char s[]=”TvNnFs”,*p; where s is an array of characters and p is character pointer, is looks like below s[0] s[1] s[2] s[3] s[4] s[5] s[6] —————————————— | T | v | N | n | F | s | \0 | —————————————— s 0x100 0x101 0x102 0x103 0x104 0x105 0x106.. (assume 0x100 is base … Read more