Debug assertion failed

I am getting this error when trying to test my program:

Debug assertion failed!

Program C;\Windows\system32\msvcp110d.dll
file: c\program files(x86)\microsoft visual studio\11.0\vc\include\xstring
line: 1143

expression invalid null pointer

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <string>

using namespace std;

int add(int x, int y){
	int z;
	z = x + y;
	return z;
}//End of Add

void display_Welcome_Msn(){
	cout << "Welcome to my function program" << endl;
}//End of display_Welcome_Msn

string your_Name(string age){
	string name;
	string name_and_age;

	cout << "please enter your name: ";
	getline(cin, name);	
	name_and_age = name;
	name_and_age.append(" ");
	name_and_age.append(age);
	return name_and_age;
}//End of your_Name

void main(){
	string age = 0;
	string display;

	display_Welcome_Msn();
	cout << "please enter your Age: ";
	cin >> age;
	display = your_Name(age);

	cout << display << endl;

	int x = 0;
	int y = 0;
	int z = 0;

	cout << "please enter numbers: ";
	cin >> x;
	cin >> y;

	z = add(x,y);

	cout << "The addition of " << x << " " << y <<" is: " << z;
}//End of Main 
In the following snippet:

string age = 0;

You can't assign a number (0) to a string. To construct an empty string use just the type and variable name.

string age;
Last edited on
Damn, i feel stupid. Thank you.
Topic archived. No new replies allowed.