Program help

What is wrong with this program code? I need help.

using namespace std;

int main () {
string g;
int count;

cout << "Enter a num\n";
cin >> g;

count = g.size() - 1; // length of number - 1

cout << g[0] << " is " << count << " digits from the right";

return 0;
Last edited on
There are some.
First, did you included <string> and <iostream>?
You need this 2 headers to use cout, cin and strings.
So, place:

1
2
#include <iostream>
#include <string> 


... at the top of the code.

And I think you've forgotten the ";" to finish the main block. Place it after return statement.
You have forgotten the closing curly bracket } at the end of main() also.
Topic archived. No new replies allowed.