program in c

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
View Poll Results: do u have any query?
y:yes 5 100.00%
n:no 0 0%
Multiple Choice Poll. Voters: 5. You may not vote on this poll

Reply

Join Date: Oct 2008
Posts: 1
Reputation: gunjanagrawal has a little shameless behaviour in the past 
Solved Threads: 0
gunjanagrawal gunjanagrawal is offline Offline
Newbie Poster

program in c

 
-1
  #1
Oct 14th, 2008
U can find all the program in c.If du u have any query about c plz ask me and also program
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 78
Reputation: rati is an unknown quantity at this point 
Solved Threads: 0
rati rati is offline Offline
Junior Poster in Training

Re: program in c

 
0
  #2
Oct 14th, 2008
Hi gunjan,

Can you please tell me what is the difference between
void function(int*d);
and
void function(int &d);
both above are function declarations and both we do the changes to the original variable passed to the function. Then what is the exact difference.

Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 40
Reputation: cutedipti is an unknown quantity at this point 
Solved Threads: 0
cutedipti cutedipti is offline Offline
Light Poster

Re: program in c

 
0
  #3
Oct 14th, 2008
H...!

Can you please tell me out of fgets() and gets() which function is safe to use and why? If possible give an example program for explanation.
Thanks & Regards
Ms. Dipti
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 113
Reputation: ahamed101 is an unknown quantity at this point 
Solved Threads: 14
ahamed101's Avatar
ahamed101 ahamed101 is offline Offline
Junior Poster

Re: program in c

 
0
  #4
Oct 14th, 2008
fgets is always safe... cause in fgets we can specify the size of the string that should be read... in such a case we can be sure only the specified no of bytes will be read...

gets is not like that... it will read whatever we give and may overwrite the memory locations not allocated for that particular string variable...


eg:
  1. char acName[20];
  2.  
  3. /* Using fgets */
  4. fgets(acName, 20, stdin);
  5.  
  6. /* Using gets */
  7. gets(acName);

For the first one using fgets, even if we give any string greater than 20 in length, it will accept only 20.... but in gets if we give string of length 30, it will accept all the 30 and over write the memory locations not allocated for acName...


Hope it clears your doubt...
regards,
Ahamed.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 273
Reputation: Sci@phy will become famous soon enough Sci@phy will become famous soon enough 
Solved Threads: 42
Sci@phy's Avatar
Sci@phy Sci@phy is offline Offline
Posting Whiz in Training

Re: program in c

 
1
  #5
Oct 14th, 2008
Originally Posted by rati View Post
Hi gunjan,

Can you please tell me what is the difference between
void function(int*d);
and
void function(int &d);
both above are function declarations and both we do the changes to the original variable passed to the function. Then what is the exact difference.

Thanks in advance
The first one is "passing arguments to pointers". In that way, you can change original variable!
Second one is "passing arguments as references".
You cannot do that in C, C always passes arguments by value (yes, even if you use pointers, but then it passes pointer as value, not original value pointed by pointer )

So, the first one is ok in C and C++
Second one is only C++
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 4
Reputation: rohanvijay is an unknown quantity at this point 
Solved Threads: 0
rohanvijay rohanvijay is offline Offline
Newbie Poster

Re: program in c

 
0
  #6
Nov 2nd, 2008
im having lot of problems in c and c++ programs...can u please tell me the sites where i ciuld find the solutions of almost all c/c++ programs..
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 146
Reputation: devnar will become famous soon enough devnar will become famous soon enough 
Solved Threads: 16
devnar's Avatar
devnar devnar is offline Offline
Junior Poster

Re: program in c

 
0
  #7
Nov 2nd, 2008
Originally Posted by rohanvijay View Post
im having lot of problems in c and c++ programs...can u please tell me the sites where i ciuld find the solutions of almost all c/c++ programs..
Solutions to ALMOST ALL C/C++ programs? That's asking for quite a lot, dontcha think? We don't even have ALMOST ALL C/C++ problems yet.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 476
Reputation: nucleon has a spectacular aura about nucleon has a spectacular aura about 
Solved Threads: 91
nucleon's Avatar
nucleon nucleon is offline Offline
Posting Pro in Training

Re: program in c

 
0
  #8
Nov 2nd, 2008
The OP was clearly trolling.
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



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC