Can anyone tells me that strstr can use to search a record with typedef struct{}??? I was just asking... and if its true then can i know how?? im just a beginner with a great project from our instructor T_T,.,.,,..,.,

strstr() is used to find a string within another string. For example, it would check if "World" is contained in the string "Hello World". strstr() is not related to structures or typedef struct.

Yeah that's i know about strstr(). But it can be usable if a word from the typedef struct{} is containes with the word to be search. Is it possible?

You will have to post a little code snippet of what you are trying to do. A typedef itself does nothing, so using strstr() on a typedef is meaningless.

I just have only created a program that will add records only coz i dont have any idea how to search aside of the strstr(). I will post the code?

Can anyone suggest me how to search records with typedef struct{}??

#include<stdio.h>

typedef struct{
	int iDnum[10];
	char Lname[20];
	char Fname[20];

}STUDENT;

typedef struct{
	int cNum[10];
	char sTitle[10];
	int unit[5];
	int fGrad[5];
}SUBJECT;

typedef struct{
	STUDENT *student;
	SUBJECT subject;
	char sem[10];
}RECORD;

void add(RECORD *profile);

int main(void)
{

	RECORD *record;

	record=(RECORD*)malloc(sizeof(RECORD));

	clrscr();
	add(record);


	getch();
	return 0;

}

void add(RECORD *profile)
{
	int i,j;
	char m;

	printf("How many students?---> ");
	scanf("%d", &i);

	for(j=0; j<i; j++)
	{
	clrscr();
	printf("Student #%d\n\n", j+1);
	printf("ID number: ");
	scanf("%d", &profile->student->iDnum);
	flushall();
	printf("Last Name: ");
	gets(profile->student->Lname);
	printf("First Name: ");
	gets(profile->student->Fname);
	}
	printf("Want to add another?--[Y/N]--> ");
	scanf("%c", &m);
	m=toupper(m);

	while(m!='N')
	{
        	printf("How many students?---> ");
		scanf("%d", &i);

		for(j=0; j<i; j++)
		{
		clrscr();
		printf("Student #%d\n\n", j+1);
		printf("ID number: ");
		scanf("%d", &profile->student->iDnum);
		flushall();
		printf("Last Name: ");
		gets(profile->student->Lname);
		printf("First Name: ");
		gets(profile->student->Fname);
		}
                printf("Want to add another?--[Y/N]--> ");
		scanf("%c", &m);
		m=toupper(m);
	}

}

sorry Subject is currently not in use...

Edited 6 Years Ago by dibbieshir: n/a

This article has been dead for over six months. Start a new discussion instead.