KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am having difficulty passing an array as an argument into int main() with default values. For example: int main(int a){} works wonderfully. As does int main(int a = 1){} Passing int main() an array also works wonderfully: int main(int a[3]) However, combining these two concepts seems break: int main(int a[1] = {0,1}) After a significant amount of googleing , I haven't found a solution. please help me SO, you're my only hope! EDIT The purpose of this, in short, is to make my code as little lines as possible, for a challenge my professor recently issued (not for points -- just for learning). The assignment is to create a recursive "12-days-of-chirstmas" program This is my current program #include <iostream> #include <string> void p(std::string v){std::cout<<v;} std::string v[13] = {"A Partridge in a Pear Tree.\n\n","2 Turtle Doves\n","3 French Hens\n","4 Colly Birds\n","5 Gold Rings\n","6 Geese-a-Laying\n","7 Swans-a-Swimming\n","8 Maids-a-Milking\n","9 Ladies Dancing\n","10 Lords-a-Leaping\n","11 Pipers Piping\n","12 Drummers Drumming\n",""}; int main(){ switch(v[12].length()){ case 12:system("pause"); return 0; case 11:p(v[11]); case 10:p(v[10]); case 9: p(v[9]); case 8: p(v[8]); case 7: p(v[7]); case 6: p(v[6]); case 5: p(v[5]); case 4: p(v[4]); case 3: p(v[3]); case 2: p(v[2]); case 1: p(v[1]); case 0: p(v[0]); }v[12] +=
Tags (comma-separated)
Save Edits
Cancel