DEV Community

Lalit Kumar
Lalit Kumar

Posted on

Remove first character from string C++

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

Top comments (0)