I am supposed to do a main program with two function named tulTerv and tulHei. First one to ask name(nimi) and second to print 'nimi' and if it's AustinPowers return value has to be 0 otherwise -1. first function not suppose to return anything(so void?) I am using string(not really sure if it's necessary otherwise) because after completing this program I am trying to do exstra program to count which letter is used the most in nimi. I am new to programming
so little help or push to right direction would be nice, thank you.
If you put a closing [/code] at the end of your code, the code will format and line numbers will show up.
line 9 nimi; <- this is just the name of a string variable. It doesn't do anything by itself.
line 32 cout <<"nimesi"<<"?"<<tulTerv(string nimi); < - when you call a function, don't include the type (string), just the name of the parameter.
Edit: Also - nimi is not declared in your main function. and you're declaring a new variable nimi in your tulHei function.
Edit again: If the first function tulTerv has to be void because of the assignment, nimi could be sent by reference so that what they input there gets stored in the nimi variable back in main.
If they're going to be entering names with spaces in between, like "Austin Powers", look into using getline because cin will stop at the blank space and only read "Austin".
Right now you're calling the tulTerv function from main with parameter nimi. Nimi hasn't been declared as a variable in main, so you should be getting a compiler error there.
Then in tulTerv, the function declaration has a local variable nimi - this is a copy of the value in nimi in the main function, but not the same variable. You then declare another local variable nimi in the body of the function. This is probably also going to give you a compiler error.
If you want the tulTerv function to return something, it can't be a void function. If you want to keep tulTerv void but update nimi back in main, you need to pass the variable by reference void tulTerv(string & nimi) <- the & is a reference operator.