I'm doing a OS class.

Trying to implement this pseudo code:

* Forking is fun! ­ Simple tips
First, fork the child process:

pid_t ForkPID;
ForkPID = fork();
Then write a quick switch statement!

switch (ForkPID) {
// ­-1, fork failure
case ­-1:
printf("Error: Failed to fork.\n"); break;
// 0, this is the child process
case 0:
// > 0, parent process and the PID is the child's PID
I get an error:

ForkEnc.cc:18: error: stray ‘\302’ in program
ForkEnc.cc:18: error: stray ‘\255’ in program

line 18 is:

case -­1:

can someone help me out.

I may be wrong but what I feel is the pid_t data type within switch() is causing the error with -1. As negativity of the choice element is not correctly defined in some cases its better if you use an integer variable to hold the ForkPid value.

int pid;

This will satisfy your needs as the returned value of pid from a child process shall always come within the limits of signed integers.

i copied a code online from some MS power point slide. the ' in text files and in Microsoft applications are different. makes sense ever tried to write an email in word and copy it onto a gmail back in the day. you use to get weird character at '.

thanks ahamed101!

This question has already been answered. Start a new discussion instead.