Why the output of function `fork` contains unexpected thing?

Viewed 38

I am writing a piece of C code using function fork(), and here is my code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main() {
    int pid;
    pid = fork();
    printf("%d", pid);
    return 0;
}

And the output is

129660%

I wonder where this % comes from, and if I write

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main() {
    int pid;
    pid = fork();
    printf("%d\n", pid);
    return 0;
}

then the output becomes:

12946
0

This fits my expectation. Can anyone tell me how % comes from?

0 Answers
Related