Given a string, print the string as left and right diagonal of the matrix (printing patterns)

Given a string, print the string as the following pattern:


input string: coderegister

output string: 
c          r
 o        e 
  d      t  
   e    s   
    r  i    
     eg     
     eg     
    r  i    
   e    s   
  d      t  
 o        e 
c          r
Implementation:

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

int main(void) {
 /* Pointer to a character */
 char *v;
 
 int N,i,j;
 
 /* allocate memory block of 256 characters & store the initial address of the block
 in character pointer 'v' */
 v=(char*)malloc(sizeof(char)*256);
 
 /* get the input string from the user */
 scanf("%s",v);
 
 /* calculate the length of the string using strlen() library function */
 N=strlen(v);
 
 for(i=0;i<N;i++)
 {
  for(j=0;j<N;j++)
  {
   /* printing left diagonal */
   if(i==j)
    printf("%c",*(v+i));
    
   /* printing right diagonal */
   else if(j==(N-i-1))
    printf("%c",*(v+j));
   
   /* print a space character ' ' in all other cases */
   else
    printf(" ");
  }
  printf("\n");
 }
 return 0;
}