what is wrong here?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education