I’m still pretty new to C++, and I’ve been making progress in making my programs not look like a cluster-bleep of confusion.
I finally got rid of the various error messages, but right now the application is crashing, and I have no idea where to start. The debugger is just throwing a random hex location.
Thank you in advance.
#include <iostream>
using namespace std;
struct Value{
public:
int Val;
}*pc;
#include "header.h"
int main () {
cout << "Enter a value: ";
cin >> pc->Val;
cout << "\nYour value is " << pc->Val << ". ";
system ("pause");
return 0;
}
In your program, pc is not a struct – it’s a pointer to the struct (because of *). You don’t initialize it to anything – it points at some bogus location. So, either initialize it in the first line of main():
Or make it a non-pointer by removing *, and use . instead of -> for member access throughout the program.