am supposed to fill an array of structure with some info and retreive it ....
what is wrong with my code! plz help! -
#include<stdio.h>
-
-
typedef struct
-
{
-
char name[20];
-
double salary;
-
int rank;
-
}employee;
-
-
void fill_array(employee);
-
employee display(employee);
-
-
void main()
-
{
-
employee arr[2], e;
-
fill_array(arr[2]);
-
e = display(e);
-
while(1);
-
-
}
-
-
void fill_array(employee arr)
-
{
-
int i;
-
for(i = 0; i<2; i++)
-
{
-
printf("name --> ");
-
scanf("%s", arr[i].name);
-
printf("salary --> ");
-
scanf("%lf", arr[i].salary);
-
printf("rank --> ");
-
scanf("%d", arr[i].rank);
-
}
-
}
-
-
employee display(employee e)
-
{
-
employee arr[2];
-
int i;
-
for(i = 0; i<2; i++)
-
{
-
printf("\n\n\n\nname --> ", arr[i].name);
-
printf("\nsalary --> ", arr[i].salary);
-
printf("\nrank --> ", arr[i].rank);
-
}
-
return e;
-
}
4 1048
fixed a few errors, I think fill_array() is working - you now need to work on display() -
#include<stdio.h>
-
-
typedef struct
-
{
-
char name[20];
-
double salary;
-
int rank;
-
}employee;
-
-
void fill_array(employee[]);
-
employee display(employee);
-
-
int main()
-
{
-
employee arr[2], e;
-
fill_array(arr); // ** removed [2]
-
e = display(e);
-
while(1);
-
-
}
-
-
void fill_array(employee arr[]) // ** added []
-
{
-
int i;
-
for(i = 0; i<2; i++)
-
{
-
printf("name --> ");
-
scanf("%s", &arr[i].name); // ** added &
-
printf("salary --> ");
-
scanf("%lf", &arr[i].salary);
-
printf("rank --> ");
-
scanf("%d", &arr[i].rank);
-
}
-
}
-
-
employee display(employee e)
-
{
-
employee arr[2];
-
int i;
-
for(i = 0; i<2; i++)
-
{
-
printf("\n\n\n\nname --> ", arr[i].name);
-
printf("\nsalary --> ", arr[i].salary);
-
printf("\nrank --> ", arr[i].rank);
-
}
-
return e;
-
}
-
thx! this is the worked out version with still one error!:
Error 4 --> error C2143: syntax error : missing ';' before 'type' -
#include<stdio.h>
-
-
typedef struct
-
{
-
char name[20];
-
double salary;
-
int rank;
-
}employee;
-
-
void fill_up(employee arr[]);
-
void display(employee arr[]);
-
-
void main()
-
{
-
employee arr[2];
-
fill_up(arr);
-
display(arr);
-
while(1);
-
}
-
-
void fill_up(employee arr[])
-
{
-
int i;
-
for(i = i; i < 2; i++)
-
{
-
printf("name --> ");
-
scanf(" %s", &arr[i].name);
-
printf("salary --> ");
-
scanf("%lf", &arr[i].salary);
-
printf("rank --> ");
-
scanf("%d", &arr[i].rank);
-
}
-
-
void display(employee arr[]) <-- error missing ';'
-
{
-
int i;
-
for(i = i; i < 2; i++)
-
{
-
printf("\n\n\n\nname --> ", &arr[i].name);
-
printf("\nsalary --> ", &arr[i].salary);
-
printf("\nrank --> ", &arr[i].rank);
-
}
-
}
thx! this is the worked out version with still one error!:
Error 4 --> error C2143: syntax error : missing ';' before 'type' -
#include<stdio.h>
-
-
typedef struct
-
{
-
char name[20];
-
double salary;
-
int rank;
-
}employee;
-
-
void fill_up(employee arr[]);
-
void display(employee arr[]);
-
-
void main()
-
{
-
employee arr[2];
-
fill_up(arr);
-
display(arr);
-
while(1);
-
}
-
-
void fill_up(employee arr[])
-
{
-
int i;
-
for(i = i; i < 2; i++)
-
{
-
printf("name --> ");
-
scanf(" %s", &arr[i].name);
-
printf("salary --> ");
-
scanf("%lf", &arr[i].salary);
-
printf("rank --> ");
-
scanf("%d", &arr[i].rank);
-
}
-
}
-
-
void display(employee arr[]) <-- error missing ';'
-
{
-
int i;
-
for(i = i; i < 2; i++)
-
{
-
printf("\n\n\n\nname --> ", &arr[i].name);
-
printf("\nsalary --> ", &arr[i].salary);
-
printf("\nrank --> ", &arr[i].rank);
-
}
-
}
You were missing a single '}' to end your fill_up function...I've added it.
THX !!! but am supposed to have the info that i ve put in the array to be be printed back but it does not happened!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mike Chirico |
last post by:
Hopefully this will help someone...
Helpful Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Last Updated: Fri Apr 16 11:47:34 EDT 2004
The latest version of this...
|
by: Yannick |
last post by:
Hi,
I have a small app in VB that implements a C++ OCX
I would like to debug the OCX from VB prog
or even better debug both at once !
I was able to do this in visual studio 6 by referencing the...
|
by: jhorner |
last post by:
I am writing a c# app and need the ability to drag a file onto the icon - this should then run the app and do something with the file.
I made the assumption that doing so would call the app with...
|
by: Jason |
last post by:
Could someone here show me how I would write a vb program to convert decimal
ip address to binary?
For example a small form with a convert button and a label for the result
and a textbox for the...
|
by: Boni |
last post by:
Dear all,
I have following problem. I created a static libruary (mylib.lib).
I compiled it with Multithreaded DLL runtime in release mode. Now I want to
give out this library. But users who...
|
by: × ×™×¨ |
last post by:
Hello,
I've already sent such a messege, hopping to be answered shortly this time.
I am practicing c/c++ programming using microsoft visual c++ express 2005
express edition. Anyway, unlike other...
|
by: momotaro |
last post by:
when I give the prog the first data it crushs !!!! and give me this message:
Unhandled exception at 0x004114c5 in CallocMalloc.exe: 0xC0000005: Access violation reading location 0x00000002.
...
|
by: momotaro |
last post by:
This is what am i asked to do:
Implement a priority queue to manage patients in an emergency room
You MUST use the files “patient.h” and “ER.c” as given.
You should write the files...
|
by: davy zhang |
last post by:
I mean every process attach like thread in wingide
like thread or tasklet in wingide
:)
maybe I asked toooo much:D
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
| |