473,835 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Someone To Debug My Prog!!!!

momotaro
357 Contributor
am supposed to fill an array of structure with some info and retreive it ....
what is wrong with my code! plz help!


Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  
  3. typedef struct
  4. {
  5.     char name[20];
  6.     double salary;
  7.     int rank;
  8. }employee;
  9.  
  10. void fill_array(employee);
  11. employee display(employee);
  12.  
  13. void main()
  14. {
  15.     employee arr[2], e;
  16.     fill_array(arr[2]);
  17.     e = display(e);
  18.     while(1);
  19.  
  20. }
  21.  
  22. void fill_array(employee arr)
  23. {
  24.     int i;
  25.     for(i = 0; i<2; i++)
  26.     {
  27.         printf("name --> ");
  28.         scanf("%s", arr[i].name);
  29.         printf("salary --> ");
  30.         scanf("%lf", arr[i].salary);
  31.         printf("rank --> ");
  32.         scanf("%d", arr[i].rank);
  33.     }
  34. }
  35.  
  36. employee display(employee e)
  37. {
  38.     employee arr[2];
  39.     int i;
  40.     for(i = 0; i<2; i++)
  41.     {
  42.         printf("\n\n\n\nname --> ", arr[i].name);
  43.         printf("\nsalary --> ", arr[i].salary);
  44.         printf("\nrank --> ", arr[i].rank);
  45.     }
  46.     return e;
  47. }
Feb 10 '07 #1
4 1061
horace1
1,510 Recognized Expert Top Contributor
fixed a few errors, I think fill_array() is working - you now need to work on display()
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  
  3. typedef struct
  4. {
  5.     char name[20];
  6.     double salary;
  7.     int rank;
  8. }employee;
  9.  
  10. void fill_array(employee[]);
  11. employee display(employee);
  12.  
  13. int main()
  14. {
  15.     employee arr[2], e;
  16.     fill_array(arr);   // ** removed [2]
  17.     e = display(e);
  18.     while(1);
  19.  
  20. }
  21.  
  22. void fill_array(employee arr[])  // ** added []
  23. {
  24.     int i;
  25.     for(i = 0; i<2; i++)
  26.     {
  27.         printf("name --> ");
  28.         scanf("%s", &arr[i].name);  // ** added &
  29.         printf("salary --> ");
  30.         scanf("%lf", &arr[i].salary);
  31.         printf("rank --> ");
  32.         scanf("%d", &arr[i].rank);
  33.     }
  34. }
  35.  
  36. employee display(employee e)
  37. {
  38.     employee arr[2];
  39.     int i;
  40.     for(i = 0; i<2; i++)
  41.     {
  42.         printf("\n\n\n\nname --> ", arr[i].name);
  43.         printf("\nsalary --> ", arr[i].salary);
  44.         printf("\nrank --> ", arr[i].rank);
  45.     }
  46.     return e;
  47. }
  48.  
Feb 10 '07 #2
momotaro
357 Contributor
thx! this is the worked out version with still one error!:
Error 4 --> error C2143: syntax error : missing ';' before 'type'
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  
  3. typedef struct
  4. {
  5.     char name[20];
  6.     double salary;
  7.     int rank;
  8. }employee;
  9.  
  10. void fill_up(employee arr[]);
  11. void display(employee arr[]);
  12.  
  13. void main()
  14. {
  15.     employee arr[2];
  16.     fill_up(arr);
  17.     display(arr);
  18.     while(1);
  19. }
  20.  
  21. void fill_up(employee arr[])
  22. {
  23.     int i;
  24.     for(i = i; i < 2; i++)
  25.     {
  26.         printf("name --> ");
  27.         scanf(" %s", &arr[i].name);
  28.         printf("salary --> ");
  29.         scanf("%lf", &arr[i].salary);
  30.         printf("rank --> ");
  31.         scanf("%d", &arr[i].rank);
  32.     }
  33.  
  34. void display(employee arr[])  <-- error missing ';'
  35. {
  36.     int i;
  37.     for(i = i; i < 2; i++)
  38.     {
  39.         printf("\n\n\n\nname --> ", &arr[i].name);
  40.         printf("\nsalary --> ", &arr[i].salary);
  41.         printf("\nrank --> ", &arr[i].rank);
  42.     }
  43. }
Feb 10 '07 #3
Ganon11
3,652 Recognized Expert Specialist
thx! this is the worked out version with still one error!:
Error 4 --> error C2143: syntax error : missing ';' before 'type'
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  
  3. typedef struct
  4. {
  5.     char name[20];
  6.     double salary;
  7.     int rank;
  8. }employee;
  9.  
  10. void fill_up(employee arr[]);
  11. void display(employee arr[]);
  12.  
  13. void main()
  14. {
  15.     employee arr[2];
  16.     fill_up(arr);
  17.     display(arr);
  18.     while(1);
  19. }
  20.  
  21. void fill_up(employee arr[])
  22. {
  23.     int i;
  24.     for(i = i; i < 2; i++)
  25.     {
  26.         printf("name --> ");
  27.         scanf(" %s", &arr[i].name);
  28.         printf("salary --> ");
  29.         scanf("%lf", &arr[i].salary);
  30.         printf("rank --> ");
  31.         scanf("%d", &arr[i].rank);
  32.     }
  33. }
  34.  
  35. void display(employee arr[])  <-- error missing ';'
  36. {
  37.     int i;
  38.     for(i = i; i < 2; i++)
  39.     {
  40.         printf("\n\n\n\nname --> ", &arr[i].name);
  41.         printf("\nsalary --> ", &arr[i].salary);
  42.         printf("\nrank --> ", &arr[i].rank);
  43.     }
  44. }
You were missing a single '}' to end your fill_up function...I've added it.
Feb 10 '07 #4
momotaro
357 Contributor
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!
Feb 10 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1498
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 document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download Format is better on the above link. I'm looking for suggestions and
0
292
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 OCX project in the main app I don't know how to do the same with .NET what is the solution ?
0
1613
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 the filename as a command line argument, but this seems to go a bit weird. I added this to my Main: static void Main(string args) { if(args != null && args.Length > 0) { // Do Something here. } else { // Do something else here.
13
9255
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 ip. So I would want 11000000 10101000 00000010 00001010 tp show up inthe label if I entered 192.168.2.10 into the text box. I have no idea even how to begin this, any help would be great.
6
2282
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 use it should be able to debug their programs (i.e. compile their programs in debug mode Multithreaded DLL DEBUG runtime ). But at link time following warning is shown and prog crashes. Do I have to
1
1283
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 compilers there is no option to actually run the prog. (Ctrl+f5,f7 in vs). What I meen is that I can't find a way to execute a prog. thanks, Hezy.
4
1430
momotaro
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. #include <stdio.h> typedef struct { char name;
2
1411
momotaro
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 patientqueue.c and patientqueue.h so that they work correctly with the two files above. For most credit: Submit two implementations of patientqueue.c, using the two approaches described above. Make sure that the queue is never full, by allowing it to grow...
1
3762
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
0
9653
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10526
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10237
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6970
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5640
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5808
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4435
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3094
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.