[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

help /g/ i am in need of your expertise...

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 18
Thread images: 3

help /g/ i am in need of your expertise...
>>
can someone help me achieve this please? I am struggling!!

Write the program reverseArgs.cpp that takes command line input arguments and prints them back in reverse order. For example, if you ran the program as ./reverseArgs first_arg second_arg, you would get an output back of second_arg first_arg.

If you ran the program as ./reverseArgs I love gorgonzola cheese, but I hate toothpaste, you would get an output back of toothpaste hate I but cheese, gorgonzola love I. This is why I (lovingly) refer to this exercise as “the Yoda program”…

If you ran the program with double quotes, then the words within should act as one unit. For example: ./reverseArgs I would rather be at "UC Santa Barbara" would output: UC Santa Barbara at be rather would I.

You are only permitted to use the iostream library.

A session should look exactly like the following example (including whitespace and formatting - note that there is no whitespace at the end of each of these lines and each printed line has a newline at the end), with all manners of different numbers for inputs and the output:
>>
something like this might help?
still learning so not good at this.
sorry op

#include <iostream>
#include <cstdlib>
using namespace std;

int main ( int argc, char *argv[] ) {

cout << "There are " << argc << " arguments here:" << endl;

for (int i = argc-1; i == 0; i--)
cout << argv[i] <<' ';

return 0;
}
>>
do you even code bro?
>>
interesting...
>>
i got nothing op
>>
i dont do c++
>>
why should we help you?
>>
>ASM
>>
>>>/dpt/
you're welcome
>>
It's okay anon try
import std.range : retro;
void main( string[] args )
{
import std.stdio : writeln;
writeln( retro(args[]) );
}

then you should tell off your teacher in class because everyone should just use C instead of C++ everyone will think youre so cool
>>
>>60174870
C is good for system programming, C++ is better for programming user space complex applications, STL is a great toolbox for common data structures such as strings regexes containers and so forth.
>>
>>60176186

What language is this
>>
#include <iostream>

int main(int argc, char* argv[]) {
for (int i = argc-1; i > 0; --i)
std::cout << argv[i] << ' ';
std::cout << std::endl;
return 0;
}

wow that was hard
>>
>>60174870

<code>

#include <iostream>
#include <cstdlib>

int main (int argc, char *argv[] ) {

std::cout << "There are " << argc << " arguments here:" << std::endl;

for (int i = argc - 1; i != 0; i--)
std::cout << argv[i] << std::endl;

return 0;
}

</code>

please do try for yourself next time
>>
>using for loops in 2017
neo-/g/ everyone!

#include <iostream>
#include <iterator>
#include <algorithm>

int main(int argc, char **argv)
{
std::reverse_copy(argv + 1, argv + argc, std::ostream_iterator<char*>(std::cout, " "));
return 0;
}
>>
>>60174870
You should probably switch majors. It's bad enough that you couldn't figure something like this out by yourself. It's even worse that you couldn't find something on stackoverflow and copy and paste.
>>
>>60179561
/thread
Thread posts: 18
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.