hi.another post by me.ehehe
pls check this code.i wonder how this would work:
this program asks for the last and first name of the user.and at the same time it must separate the first names of the user.for example, the name of the user is juan miguel bautista. it will store (and print) the names juan and miguel in an n-dimensional array inside a structure.

hope you will help me with this.:D

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

#define MAXLEN 15
#define TEMP_MAX 225

typedef struct name {
	char lastname [MAXLEN];
	char firstname [MAXLEN][MAXLEN];
} name_t;

int main(void)
	char firstname [TEMP_MAX];
	char space[1] = {' '};
	name name_t; 
	int i=0, j=0, k=0, l=1;
	puts("\t\tThe Sorting Hat");

	printf("\tYour Last Name? ");
	fgets(name_t.lastname, sizeof(name_t.lastname), stdin);
	name_t.lastname[strlen(name_t.lastname)-1] = '\0';

	printf("\tYour First Name? ");
	fgets(firstname, sizeof(firstname), stdin);
	firstname[strlen(firstname)-1] = '\0';
			if(firstname[i] != space[0]){
				name_t.firstname[j][k] = firstname[i];
			while(firstname[i] == space[0]){
				if(firstname[i] != space[0]){
					name_t.firstname[j][k] = firstname[i];
	printf("Interesting. You have %d names:\n", j+1);
		printf("%d. %s\n",l, name_t.firstname[j]);
	return 0;

name_t on line 16 overrides the name_t typedef on line 10. Bad idea.

line 15 could be declared as simply char space = ' '; . No need for the array syntax.

I fail to see why you need first_name to be a two dimensional array of 255 characters each dimension! That's enough for 255 names each name 255 characters long. The world's longest name is only 13 words.

BTW the longest name in the world is "Captain Fantastic Faster Than Superman Spiderman Batman Wolverine Hulk And The Flash Combined. "

According to 1978 Book of World Records the longest sir name was 590 characters.

Edited 6 Years Ago by Ancient Dragon: n/a

The trivia is what hooked me. Lol
Awesome trivia!
This article has been dead for over six months. Start a new discussion instead.