0

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,.,.,,..,.,

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by Dave Sinkula
Featured Replies
  • All that gets() and clrscr() stuff makes me want to post [URL="http://www.daniweb.com/tutorials/tutorial45806.html"]this[/URL] so you might take user input in a better way. Read More

0

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.

0

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?

0

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.

0

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 by dibbieshir: n/a

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.