very short code question plz help

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 16
Reputation: GigaCorp is an unknown quantity at this point 
Solved Threads: 0
GigaCorp GigaCorp is offline Offline
Newbie Poster

very short code question plz help

 
0
  #1
May 10th, 2008
int patientstomemory(patientstruct (*patientstructpointer)[maxpatients])
{
patientstruct patientstruct1[maxpatients];
patientstruct1= (*patientstructpointer);



1>c:\documents and settings\patrick\my documents\hgkbklhb\hgkbklhb\hgkbklhb.cpp(88) : error C2106: '=' : left operand must be l-value


whats wrong? very important, working on semester project due monday
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: very short code question plz help

 
0
  #2
May 10th, 2008
You can't assign a whole array, you need to copy it one entry at a time.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 678
Reputation: Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold Sky Diploma is a splendid one to behold 
Solved Threads: 101
Sky Diploma's Avatar
Sky Diploma Sky Diploma is offline Offline
Practically a Master Poster

Re: very short code question plz help

 
0
  #3
May 10th, 2008
The Right hand value over here in

  1. patientstruct1= (*patientstructpointer);

Is an error because a the stucture is taking in values from a pointer, which is not allowed.
An example program is written below so that it may help you in solving your problem

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. struct sky{
  8. char a;
  9. int b;
  10. };
  11.  
  12. sky art;//Object
  13. sky *start;
  14.  
  15. art.a='s';
  16. art.b=9;
  17.  
  18.  
  19. *start=art;//Pointer is pointing to art which is legal.
  20.  
  21. sky mart;
  22.  
  23. //*start=mart; // This is illegal in c++ and produces the error.
  24.  
  25.  
  26. //Therefore pass values in this way
  27.  
  28. mart.a=start->a;
  29. mart.b=start->b;
  30.  
  31.  
  32. cout<< mart.a<<"\n\a"<<mart.b<<"\a";
  33. cin.get();
  34. return 0;
  35. }

Hope this solves it out.
1. Please Mark Your Thread as Solved After Getting Your Answers.
2. Please Use CODE TAGS .
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 16
Reputation: GigaCorp is an unknown quantity at this point 
Solved Threads: 0
GigaCorp GigaCorp is offline Offline
Newbie Poster

Re: very short code question plz help

 
0
  #4
May 10th, 2008
oh may the programming gods bless you
now i know whats wrong ill try to figure out how to do it
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC