[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] Why my strings are not going to be XOR?

Just another try on the code base of the question , #include<iostream> #include<string.h> using namespace std; int main() { string pass; string enc=”akdhigfohre”; string x = “”; string y = “”; cout<<“Enter new password: “; cin>>pass; cout<<“\n\nYour New Password is:” << pass<<endl; for(size_t i = 0; i < pass.size(); ++i){ x += pass.at(i)^enc.at(i%enc.size()); } cout<<“\n\nEncrypted … Read more

[Solved] both are char but i get, invalid conversion from `char’ to `char*’ [closed]

Not only are you confusing the order or parametres in strcpy (it’s destination, then source, so strcpy(xstring, animalsarray[j][0]); would have it’s parametres inverted), you’re confusing a char with a pointer-to-char. xstring is a char, and you’re trying to use it as a string. If you want to set all the elements of the array to … 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]