DEV Community

loading...

Remove first character from string C++

whataluckyguy profile image Lalit Kumar ใƒป1 min read

1.Declare a string
2.Declare an integer variable
3.Print String Statement
4.Input from user string any
5.integer variable call for string length
6.return erase() function


title: "originally posted here ๐Ÿ‘‡"

canonical_url: https://kodlogs.com/blog/769/remove-first-character-from-string-c

#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    int n;
    cout<<"String = ";
    cin>>s;
    n=s.length();
    s.erase(s.begin());
    cout<<s;
}
Enter fullscreen mode Exit fullscreen mode

Read more in original post

Discussion (0)

pic
Editor guide