Trying to learn on my own..

Ok, here is the deal. I have a learning disability as well as slight damage from a car accident to my brain (not exactly Einstein here but I get by in life). I taught myself some very very low level stuff in basic (back in 1983 or 84 before I was even 10 years old using an Atari 800XL computer), so I figure I should be able to grasp enough of c++ to help me with learning more of it since this is the age of information. I have worked through several tutorials to completion with satisfactory scores. I figure my next step is to attempt to write a program of my own but I have run into a problem. I am getting the error message

1
2
 
  '{': missing function header (old-style formal list?)


while compiling to check my work thus far. The program I am attempting to write should be a fairly simple one. All it is for is to take a single word (input from a user) and translate it to "pig-latin".

For those of you whom never played the child hood language all you do is take the first letter of the word and put it at the end of the word and then add an 'A' after it. Here is the code I have thus far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

#include <iostream>
#include <string>


using namespace std;
	

int main();
{

// creating a string variable to hold a word
	string word;

// Ask user to input a word to be translated to "PIG_LATIN"
cout ("Enter a word to be translated to PIG_LATIN:\n");
cin >> word;

int lengthOFword = (word.length)
return 0
}


All I am asking for is how to fix the header situation. I want to try to write the most of this on my own so as to learn from it. Thank you in advance for any and all assistance.

Several syntax mistakes.

line 9: There should be no semi-colon after int main()
line 16: The insertion operator (<<) should be used for cout
line 19: word.length(), NOT word.length
line 20: Should be a semi-colon after return 0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>
using namespace std;
	

int main()
{

    // creating a string variable to hold a word
    	string word;
    
    // Ask user to input a word to be translated to "PIG_LATIN"
    cout << "Enter a word to be translated to PIG_LATIN:\n";
    cin >> word;
    
    int lengthOFword = word.length();
    return 0;
}

Last edited on
Thank you Arslan7041. That solved it. I am trying to write this so that maybe I will learn from my mistakes as such. Now I am going to attempt to write more of this program. I hope you all are having a lovley day.
Topic archived. No new replies allowed.