Q:

Simple PIPE program does reads strange characters

I have created a straightforward program with processes that does one very basic thing: the child writes, the father reads. 
Strangely, the father only read strange characters and I do not know why (I've been trying for past hour to deduct why, but no success. 
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

// cp = Child -> Parent,  pc = Parent -> child
int cp[2], pc[2];
int main (){
    char str[13]="Hello World";
    char received[13];
    pid_t pid;
    pid = fork();
    if (pid == -1){
        printf("An error occured!\n");
        exit(1);
    }
    int res = pipe(cp);
    if (res == -1){
        printf("Error when creating pipe!..\n");
        exit(1);
    }
    //pipe(pc);
    if (pid==0){
        // Child process
        close(cp[0]);
        write(cp[1], str, 10);
        close(cp[1]);
        exit(0);
    }else{
        // Parent process
        close(cp[1]);
        read(cp[0], received, 10);
        close(cp[0]);
        printf("We received from child: %s\n", received);
        exit(1);
    }
    return 0;
}

Examples of outputs:
1) We received from child: @
2) We received from child: �XCV�

A:

Your main problem is that you create your pipe after that you fork your process. 
int cp[2];
int res = pipe(cp); // create the pipe before
if (res == -1) {
    perror("pipe()");
    return 1;
}
pid_t pid = fork(); // so child and parent share the same pipe
if (pid == -1) {
    perror("fork()");
    return 1;
}

A tutorial about pipe grant by codekaizer. 

read() is used to read bytes from a file descriptor.  It will not add a nul byte at the end of the buffer. 
You must put it yourself:
char received[42];
ssize_t n = read(cp[0], received, sizeof received - 1);
if (n == -1) {
    perror("read()");
    return 1;
}
received[n] = '\0';
printf("%s\n", received);

