+ 1
How can I access sa particular letter in string?
Suppose I take input of a string and want to print only its first letter. How can I do that?
4 Answers
+ 1
#include <iostream>
#include <string>
int main(int argc, char *argv[])
{
std::string input;
std::getline(std::cin,input);
std::cout<<input[0];
}
//here 0 is the index of first character
+ 3
Aditya rout and Ipang thanks for helping me understand
+ 2
Various ways to obtain first character in a basic string.
(Edit)
Naam Mein Kya Rakha Hai đ
Next time please include language specifics earliest in the tags, just to avoid misunderstanding : )
https://code.sololearn.com/cpxpf97RkL1F/?ref=app
+ 1
BroFar
Sir, my DM still doesn't work.
I have noted the OP by edits though ...