In the following program i just try to copy some string to the array and print it in another function.
I am getting segmentation fault .Could someone point out what i did wrong ?
#include <stdio.h>
#include <string.h>
#define MAX_STR_LEN 20
void print_str(char str[][],int count);
int main()
{
char str[2][MAX_STR_LEN];
strncpy(str[0],"hello",MAX_STR_LEN);
strncpy(str[1],"world",MAX_STR_LEN);
print_str(str,2);
return 0;
}
void print_str(char str[][],int count)
{
int i;
for(i=0;i<count;i++)
printf("%s\n",str[i]);
}