with the wp_insert_post i want to insert text from a html-form. This is my string i want to insert:
#include<stdio.h>
int main() {
printf("Hello World\n");
return 0;
}
when i publish the post it looks like this:

“Hello Worldn” should be “Hello World\n” and stdio.h after } should not be there.
EDIT:
It should look like this:

You need to add slashes as wp_insert_post
will remove them:
$data = array(
'post_content' => '
#include<stdio.h>
int main() {
printf("Hello World\n");
return 0;
}
',
);
wp_insert_post( wp_slash( $data ) );
Update: After running the above, this is exactly what I get in the editor:
#include
int main() {
printf("Hello World\n");
return 0;
}