-
Problem
A window(general protection exception) pops up when I try to compile this:
Code:
//Filename: ptch.cpp
//Fuction: Patch Testing
#include <fstream.h>
#include <conio.h>
#include <string.h>
#include <stdio.h>
int main(void)
{
char *p;
char input[100];
ifstream b_file("patch.txt");
b_file >> input;
b_file.close();
int lp=1;
while(lp!=0)
{
char nl[]="\n";
strcpy(p,nl);
lp=lp-1;
}
p = strtok(input, "2");
if(p) cout << p;
clrscr();
p = strtok(NULL, "2");
cout << p;
getch();
}
The notepad file(in the same directory) says this:
What's wrong?
-
A pointer that points to nothing or a random memory location isn't much use. You need to point p at some area of memory before you can use it. Apart from that I'm not really sure what you're trying to do.