I made struct called 'person'. I want to enter name and surname (by that order and they are seperated by space) of a person. In my code for some reason printf(); does not work properly. 

```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 3

struct person{
    char name_surname[50];   
};

int main(void){

    struct person M[N];
    int i,j;

    for(i=0;i<N;i++){

        printf("Enter name and surname:\n");
        fflush(stdin);
        gets(M[i].name_surname);

    }
    for(i=0;i<N;i++){
        for(j=0;j<strlen(M[i].name_surname);j++){
            if(M[j].name_surname!=' '){
                printf("%c", M[i].name_surname);
            }
            else{
                break;
            }
        }   
    }

    return 0;
}

```