'I was trying to print a telephone directory......but i was not able to do so

Here is the code i had written.... it is taking the input but not able to give the out put.... please look at it please suggest me if i have some sort of error in this code.... I have also tried it by doing some changes in the code...but i was not able to sort the error

#include <stdio.h>
#include  <stdlib.h>
#include <string.h>
int main()
{
     char s_name[10][15],first_name[10][15],
               second_name[10][15];
     char power[10][25],_[10][25];
     int i,n;
     printf("Enter number of people :  ");
     scanf("%d",&n);
     long int *p_num  =  (long int *)malloc(n*sizeof(long int));
     for(i=0;i<n;i++)
     {
          printf("Enter surname name of person %d  :  ",i+1);
          scanf("%s",s_name[i]);
          printf("Enter first name of person %d       : ",i+1);
           scanf("%s",first_name[i]);
          printf("Enter Second name of person %d    : ",i+1);
          scanf("%s",second_name[i]);
          printf("Enter the number of person %d       : ",i+1);
          scanf("%ld",p_num+i);
     }
          for(i=0;i<n;i++)
          {
               strcpy(_[i],first_name[i]);
               strcat(_[i],",");
               strcat(_[i],second_name[i][0]);
               strcat(_[i],".");
               strcat(_[i],s_name[i][0]);
          }

     printf("\n\n\n\n\n");
     printf("********************** The Telephone Directory **********************\n\n\n ");
     printf("Full name                       Phone number  ");
     for(i=0;i<n;i++)
     {
          printf("%-20s \t\t %ld ",_[i],*(p_num+i));
     }
     return 0;

}

Blockquote

c


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source