#include <stdio.h>
void main()
{
char couples[3][50] = { "Paul Kathy", "John Nora", "Martin Mary" };
char husbands[3][50];
char wives[3][50];
int i = 0;
int j = 0;
puts("Husbands: ");
for (i = 0; i < 3; i++)
{
while (couples[i][j] != ' ')
{
couples[i][j] = husbands[i][j];
j++;
}
husbands[i][j] = '\0';
puts(husbands[i]);
j = 0;
}
}
I have created a program similar to this before and it ran perfectly. However while this does build and compile successfully, it doesn't run correctly. Essentially, I'm trying to separate couples into a separate string based up the space character. What am I doing wrong?