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 tryimport 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