- int search(student_record db[], int count)
-
{
-
int i;
-
char fname[30], lname[30];
-
printf("Enter the employees first name:\n");
-
scanf("%s",fname);
-
printf("Enter the employees last name:\n");
-
scanf("%s",lname);
-
printf("\n\n");
-
-
for(i=0; i<count; i++)
-
{
-
if((strcmp(fname,db[i].firstname)==0) && (strcmp(lname,db[i].lastname)==0))
-
{
-
printf("Record Found!\n");
-
printf("Record[%d] = %s %s %s %s %s %s %s \n\n", i ,db[i].firstname,db[i].lastname,db[i].ssno,db[i].city,db[i].state,db[i].year,db[i].sex);
-
return i;
-
}
-
return -1;
-
}
-
}
This will find a record in my database but when it prints it will print the first element in the array. Which makes sense because on this line: - printf("Record[%d] = %s %s %s %s %s %s %s \n\n", i ,db[i].firstname,db[i].lastname,db[i].ssno,db[i].city,db[i].state,db[i].year,db[i].sex);
it is using the variable of i as 0. I just need it to be able to print the record taht it found.
2 1537
Just moving it to the top to make sure it doesnt get missed.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dariusz |
last post by:
I want to use arrays in my website (flat file for a guestbook), but despite
having read through countless online tutorials on the topic, I just can't
get my code to work.
I know there are...
|
by: cpptutor2000 |
last post by:
I am using an STL list to store data packets in a network simulator.
The data packets are really C structs, which have other C structs
inside them. These structs contain
unsigned char arrays of...
|
by: Paminu |
last post by:
Why make an array of pointers to structs, when it is possible to just make
an array of structs?
I have this struct:
struct test {
int a;
int b;
|
by: Marty |
last post by:
I am new to C# and to structs so this could be easy or just not
possible.
I have a struct defined called Branch
If I use Branch myBranch = new Branch(i); // everything works
If I use Branch...
|
by: rllioacvuher |
last post by:
I need help with a program. I have implemented that following header file with an unordered list using one array, but i need to be able to use an ordered list and 2 arrays (one for the links and one...
|
by: Francois Grieu |
last post by:
Hello,
is the size of a type, defined using typedef as a collection of
arrays of unsigned char, the sum of the size of the arrays ?
After simplifying my question, it probably is equivalent to:...
|
by: Cliff Martin |
last post by:
Hi,
I am reading a fairly large file a line at a time, doing some
processing, and filtering out bits of the line. I am storing the
interesting information in a struct and then printing it out....
|
by: rajash |
last post by:
Thanks to everyone on this forum for their helpful comments, now here
is my solution to Exercise 1.17, pretty short and neat!
// print lines longer than 80 chars
char x; // allocate buffer
...
|
by: sanjay.vasudevan |
last post by:
Why are the following declarations invalid in C?
int f();
int f();
It would be great if anyone could also explain the design decision
for such a language restricton.
Regards,
Sanjay
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |