what is wrong here?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question
100%

what is wrong here?

TDM-GCC 4.9.2 64-bit Release
(globals)
Project Classes Debug
Untitled1qeq.cpp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
1
2
4
5
int main()
7
char name[100];
8
int PID;
printf("Enter the user name:");
scanf ("%s",&name);
PID=fork();
if (PID == 0) /* Child process */
printf("\n%d This is child process %s",PID,name);
else /* Parent process */
printf("\n%d This is parent process %s",PID, name);
exit(0); /* Executed by both processes */
return e;
9
10
11
12
13
14
15
16
17
18
88 Compiler (2)
Resources dh Compile Log V Debug a Find Results
Close
Line
Col
File
Message
In function 'int main()':
C:\Users\jccnt\OneDrive\Desktop\Untitled1qeq.cpp
C:\Users\jccnt\OneDrive\Desktop\Untitled1qeq.cpp
11
14
[Error] 'fork' was not declared in this scope
Transcribed Image Text:TDM-GCC 4.9.2 64-bit Release (globals) Project Classes Debug Untitled1qeq.cpp #include <stdio.h> #include <stdlib.h> #include <string.h> 1 2 4 5 int main() 7 char name[100]; 8 int PID; printf("Enter the user name:"); scanf ("%s",&name); PID=fork(); if (PID == 0) /* Child process */ printf("\n%d This is child process %s",PID,name); else /* Parent process */ printf("\n%d This is parent process %s",PID, name); exit(0); /* Executed by both processes */ return e; 9 10 11 12 13 14 15 16 17 18 88 Compiler (2) Resources dh Compile Log V Debug a Find Results Close Line Col File Message In function 'int main()': C:\Users\jccnt\OneDrive\Desktop\Untitled1qeq.cpp C:\Users\jccnt\OneDrive\Desktop\Untitled1qeq.cpp 11 14 [Error] 'fork' was not declared in this scope
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Driver code
int main()
{
    char name[100];
    int PID;
    printf("Enter the user name: ");
    scanf("%s",name);
    PID = fork();
    if(PID == 0){
        printf("\n%d This is child process %s",PID,name);
    }
    else{
        printf("%d This is parent process %s\n",PID,name);
    }
    exit(0);
    return 0;
}                                                                                                                                                                                                                                                              It does let me enter the number of fork but only 1 character can be enter in the username. If I type multiple character to username It does not let me enter the number of fork. I use ubuntu. 

The command that I used in ubuntu

>gedit prog.c

(CODE FILE)

>cc -c prog.c

>cc -o prog prog.c

>./prog

Correct me please

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Requirement Analysis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning