Segmentation Fault

I'm getting a segmentation fault whenever i run this code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <windows.h>
#include <iostream>
using namespace std;

void print(string i)
{
     cout << i << '\n';
}


void quit(int i)
{
     cin.ignore(i,'\n');
     cin.get();
}


void run(char* i)
{
     ShellExecute(GetDesktopWindow(), "open", i, NULL, NULL, SW_SHOWNORMAL);
}

I was able to track the fault down to the "Print" function.
Any suggestions on how to fix it?
The error occurs there, but in my opinion it's a manifestation of a mistake you made in some other part, since the function itself doesn't do anything out of the ordinary.
I'd look for buffer overflows, double deletions, etc.
Last edited on
check "i" if its coming null as it should be a full path of .exe file which you are trying to execute.

instead of GetDesktopWindow() try putting NULL.
Topic archived. No new replies allowed.