I apologize if this a really stupid question... I'm primarily a Java programmer and don't know the "ins and outs" of most other languages.
How can you determine the char of a specific location on a string?
For instance in java I could do this:
String asd = "kittens";
char jkl = asd.charAt(2);
// jkl is equal to 't'
is there a similar functionality in c? Thanks in advance!
I apologize if this a really stupid question.
It is because your post title says string and your code says String. How you get a character at the nth position in each is completely different.
Edit: Oops. Maybe I should read the whole post, first.
With a String, you can use charAt() to get the nth character. With a string, it’s simply the [n]th character. No manipulation needed.
char str = “This is a string”:
char ltr = str;
ltr is ‘s’.
Ah, thank you for your fast reply. That answered my question perfectly!
However now I have a new question... is there a difference between "string"s and "String"s?
I only thought there was one, "String". what is a "string"?
EDIT: nevermind, I should had done research before asking that. I found the answer online.