Informatics3-2024/Homework2

A MathWikiből
(Változatok közti eltérés)
Kkovacs (vitalap | szerkesztései)
(Új oldal, tartalma: „Send an email with the solutions as attachments (.c, .cpp or if you have .h and .hpp files) to the following email address: tofihomework+2024info3en@gmail.com You shou…”)
Újabb szerkesztés →

A lap 2024. március 8., 16:24-kori változata

Send an email with the solutions as attachments (.c, .cpp or if you have .h and .hpp files) to the following email address: tofihomework+2024info3en@gmail.com

You shouldn't attach the compiled programs. If you feel like you're sending a lot of files (5+) you can put them in a zip, but you don't need to.

Space not included

Write a C++ function that takes a C string. It returns a copy of this string that contains no spaces. Write a main function to test it.

The result string doesn't have to be the correct size. You can create a string exactly as long as the input string, just be sure to put the terminal 0 character at the right place.

As an example with the "Falkor is a flying dog" input the output of the function should be the string "Falkorisaflyingdog".

Don't be afraid to use lots of couts in the code while you're testing or are looking for errors. It helps a lot if you can see what actually happens in there.

Hints at the end of the page (if you have the time/perseverance, first try to solve it without the help, or just think about how you would solve it).




































































First you'll need to figure out the length of the input string so that you can create the output string. You don't have to copy the input string completely. You could decide during the copying whether you include the given character in the new string or not. Though this way you'll need 2 "cycle variables" inside 1 cycle (because when you skip a space in the new string, the indices of the input and new string start to misalign).

Személyes eszközök