I am new to c++ and I am confused on where to exactly start. I don't understand what argc and char* argv means and how should I change it to an int. The following pictures show the prompt and the tests I need to pass in order for the code to work. Thanks.
#Coding HW about Vectors
10 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
@astral knoll
Screenshots!
Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!
#include <vector>
std::vector<int> make_vector(int argc, const char* argv[]);
this is my code so far
If you don't know what they mean the first thing to do then is to try to understand what argc and argv are. The argc stands for argument counter and the argv stands for argument vector.
They're basically command line arguments and if you don't know what this is you can look it up. I think the first answer explains it well from this link. https://stackoverflow.com/questions/3024197/what-does-int-argc-char-argv-mean
I would advise that you try to do it on your own after reading this carefully and if you encounter errors you are having a lot of trouble with you can ask for more help
i guess it could be treated as 2d array. Length of outer array is fixed right? and the intner array is an array of 2 bytes, first on is char type '0' and anotehr is 0 . so iterating by 2 bytes and picking only first byte of 2 seems like a solution. Also char '0' is ASCII ,could be case to int but it's value is 48 decimal so subtracting 48 will give 0 decimal.
so how would I convert vector data into an int?
you're jumping too far ahead. First think about looping through the argument counter and then setting the argument vector values into another variable
std::vector<int> intvector;
const char * data [] ={"0","0"};
int data_len = 2;
for(int i=0;i<data_len;i++){
int val = (int)data[i][0] - 48;
intvector.push_back(val);
}