473,500 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

copy strings program without strCopy()

20 New Member
I am doing private studies on c++ and have no tutors. Can someone help me with the following. I will write exams end of the year in c++

5. rewrite the following code correcting all problems found

void calculatevalues (const int &a, float *b, int &c)

{
d = 20.4;

if (*a =0)

*a += 1
c = a +d;

else

b= c/d ;

c= a- b +d;

}

Hint if a =4, b =0.0 and c=5 when this function is called, their values when this fucntion returns should be a=4, b=0.25 and c= 24.15

6 a The string class in the standard c++ library is a template for any type character of character representation.

write a function called copy which takes two parameters of the string type. The first parameter is the source string ( or the string to be copied) and the second parameter is the target string ( or the string that recieves the copy). This function need not return anything.

One is not allowed to use the fuction strcpy (.....)!

b show how you would use (or call) your fucntion by writting a code to cpy one string into another
Feb 9 '07 #1
2 1845
nickyeng
254 Contributor
please use code tag to list the coding.

Expand|Select|Wrap|Line Numbers
  1. void calculatevalues (const int &a, float *b, int &c)
  2. {
  3. float d = 20.4;  
  4.  
  5. if (*a =0) {
  6.  
  7. *a += 1;
  8. c = a + d;
  9. } else {
  10.  
  11. b = c/d ;
  12. c = a - b + d;
  13. }
  14.  
the errors mostly were syntaxz error?

the calculation you fix it yourself or some other ppl would help you by then.

all the best.
Feb 9 '07 #2
jchimanzi
20 New Member
please use code tag to list the coding.

Expand|Select|Wrap|Line Numbers
  1. void calculatevalues (const int &a, float *b, int &c)
  2. {
  3. float d = 20.4;  
  4.  
  5. if (*a =0) {
  6.  
  7. *a += 1;
  8. c = a + d;
  9. } else {
  10.  
  11. b = c/d ;
  12. c = a - b + d;
  13. }
  14.  
the errors mostly were syntaxz error?

the calculation you fix it yourself or some other ppl would help you by then.

all the best.
thank you very much it worked out
Feb 9 '07 #3

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

Similar topics

75
8188
by: Massimo | last post by:
I'm planning to develop a .NET application using C#, in order to sell it as a shareware and/or as a full package, so I'll need a good way to protect it against piracy. I know some ways to protect...
1
17904
by: Matt Garman | last post by:
What is the "best" way to copy a vector of strings to an array of character strings? By "best", I mean most elegantly/tersely written, but without any sacrifice in performance. I'm writing an...
11
1398
by: stroker_ace | last post by:
Hi, I am working on a problem where I need to implement a string buffer that I can remove an arbitary length char* from one end and add them to the other. So far the only way I have thought...
4
1390
by: Lafer | last post by:
Hello, I am attempting to write a terminal interface program using PowerPC Assembly/C, where I am using an integer-to-ASCII conversion algorithm. Unfortunately, I have run into some difficulties...
4
8775
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where...
5
3737
by: swarsa | last post by:
Hi All, I realize this is not a Palm OS development forum, however, even though my question is about a Palm C program I'm writing, I believe the topics are relevant here. This is because I...
5
2372
by: Fred | last post by:
Hi: I've got the following request: (suppose the required head file is included) vector<stringvec; // .......... // push some items into vec string str; // here I want to copy some range...
7
1746
by: Jeffrey Barish | last post by:
(Pdb) myclass MyClass( 0, 0, 'A string', 123.45) (Pdb) copy.copy(myclass) *** TypeError: TypeError('__new__() takes at least 4 arguments (2 given)',) I see 4 arguments (actually, 5 because...
10
4939
by: Jason | last post by:
I want to create a simple program with Two buttons on the form. BUTTON 1 - BACKUP PREFS this will do the following: Copy C:\Documents and Settings\%USERNAME%\Application Data\FileZilla...
0
7134
marktang
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,...
0
7014
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...
0
7180
Oralloy
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,...
0
7229
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...
1
6905
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...
1
4921
isladogs
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...
0
4609
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...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
311
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...

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.