Please Help me out!! After many tries I'm unable to return a string from a function. Please reply with the corrected code! I want it for my High School. Thanks in advance!
I've shortened the code here.
#include<iostream>
#include<iomanip>
#include<conio.h>
#include<cstdlib>
#include<fstream>
#include<string.h>
#include<stdio.h>
using namespace std;
string logdisplay(int log)
{string logname[40];
switch(log)
{case 1:*logname="BlueDart";
break;
case 2:*logname="FedEx";
break;
case 3:*logname="Delhivery";
break;
case 4: *logname="DTDC/FirstFlight";
break;
case 5: *logname="Ecom Express";
break;
case 6: *logname="India Post";
break;
case 7: *logname="ATS";
break;
case 8: *logname="Ekart";
break;
case 9: *logname="Aramex";
break;
default: cerr<<"Wrong Choice!!"; exit(0);}
return *logname;
}
int main()
{
int category;
cout<<"Enter the category number corresponding to its serial number"<<endl<<"1. Baby & Mom"<<endl<<"2. Books & Magazines"<<endl<<"3. Cameras & Optics"<<endl<<"4. Automotive"<<endl<<"5. stringity"<<endl<<
"6. Clothing & Accessories"<<endl<<"7. Coins & Notes"<<endl<<"8. Collectibles"<<endl<<"9. Fitness & Sports"<<endl<<"10. Fragrances, Beauty & Health"<<endl;
cout<<"11. Fun Stuff"<<endl<<"12. Games & Accessories"<<endl<<"13. Home and Living"<<endl<<"14. Home & Kitchen Appliances"<<endl<<"15. Jewellery & Precious Coins"<<endl<<"16. Kitchen & Dining"<<endl<<"17. Laptops & Computer Peripherals"<<endl<<"18. LCD, LED & Televisions"<<endl<<"19. Memory Cards, Pen Drives & HDD"<<endl;
cout<<"20. Mobile Accessories"<<endl<<"21. Mobile Phones"<<endl<<"22. Gaming Consoles"<<endl<<"23. Movies & Music"<<endl<<"24. Musical Instruments"<<endl<<"25. Services & Real Estate"<<endl<<"26. Shoes"<<endl<<"27. Stamps"<<endl<<"28. Stationery & Office Supplies"<<endl<<"29. Tablets & Accessories"<<endl;
cout<<"30. Hardware & Electricals"<<endl<<"31. Toys, Games & School Supplies"<<endl<<"32. Travel"<<endl<<"33. Watches"<<endl<<"34. Warranty Services"<<endl<<"35. Wearable Devices"<<endl<<"36. Audio & Home Entertainment"<<endl<<"37. Everything Else"<<endl;
cin>>category;
string categn1[40];
categn1=categdisplay(category);
cout<<"Category - "; cout<<categn1;
cout<<" Note: Above calculations are not 100% accurate. These are approximate figures only and may vary based on exact product weight and packaging dimensions.";
getch();
}