what is wrong here?
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1a38af93-ae9f-4589-9f53-1b20a6b35068%2Fb24bc528-17fa-4e2b-b95a-c43dd4c0cef7%2Fvso58je_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
#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
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)