Call for the method?

Helo, so i made this code, i want my method to write out this information when i call for it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 #include <string>
#include <iostream>

using namespace std;



int main() {
	string namn;
	int alder;

	cout << "skriv in namn: " << endl;
	cin >> namn;
	cout << "skriv in ålder: " << endl;
	cin >> alder;

	skrivut(namn, alder);     // <<< ----- here how do i call for it?
	return 0;

}

void skrivut(string namn, int alder) {
	cout << " ditt namn : " << namn << endl <<
		"din ålder : " << alder << endl;
}


Error is "skrivut":identifier not found

I am aware of that void cant return a value? but it should be possible to get it to print out the stuff when i call for it or?

Last edited on
Move definition of skrivut before main.
Yeah, changed to this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <string>
#include <iostream>

using namespace std;

void skrivut(string namn, int alder) {
	cout << " ditt namn : " << namn << endl <<
		"din ålder : " << alder << endl;
}

int main() {
	string namn;
	int alder;

	cout << "skriv in namn: " << endl;
	cin >> namn;
	cout << "skriv in ålder: " << endl;
	cin >> alder;

	void skrivut();
	return 0;

}



it makes the stuff i want it to do in main, but it wont print out skrivut() method :/
Last edited on
Why did you change your main?
What you mean?

does not matter if i have
void skrivut(string, int);
or void skrivut(string name, int alder);

same result, noting after i typed in alder
Use the main function from the first code block with the placement of skrivut from the second.
Topic archived. No new replies allowed.