"c++ give options string" Code Answer's
You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "c++ give options string" answered properly. Developers are finding an appropriate answer about c++ give options string related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like c++ give options string. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on c++ give options string.
c++ give options string
string StringOptionsBox(int count, ...)
{
bool bValidSelection = 1;
do
{
//set the border options
char sczCorners = '+';
char sczVerticalFillers = '|';
char sczHorizontalFillers = '-';
char sczGeneralFillers = ' ';
// set the spacing options
int iLineWidth = 50;
int iOptionSpace = 25;
int iNumberSpace = 3;
int iTabSpace = 3;
int iRightSpace = iLineWidth - iOptionSpace - iNumberSpace - iTabSpace - 1;
va_list arguments; // A place to store the list of arguments
va_start(arguments, count); // Initializing arguments to store all values after count
//////////////////////////////////////////////////////////////////////////////////////
// LAYOUT THE INTERFACE AND PROMPT THE USER'S SELECTION //
//////////////////////////////////////////////////////////////////////////////////////
//Top line of the output
cout << sczCorners << setw(iLineWidth) << setfill(sczHorizontalFillers) << ""
<< sczCorners << "\n";
//Main Lines of the output
for (int i = 1; i <= count; i++)
{
cout << sczVerticalFillers;
cout << setw(iNumberSpace) << setfill(sczGeneralFillers) << right << i << ".";
cout << setw(iTabSpace) << setfill(sczGeneralFillers) << left << "";
cout << setw(iOptionSpace) << setfill(sczGeneralFillers) << left << va_arg(arguments, char *);
cout << setw(iRightSpace) << setfill(sczGeneralFillers) << left << "" << sczVerticalFillers << "\n";
}
//Bottom line of the output
cout << sczCorners << setw(iLineWidth) << setfill(sczHorizontalFillers) << "" << sczCorners << "\n";
va_end(arguments); // Cleans up the list
// User's selection process
string sSelected;
cout << "\nSelect one of the above options: ";
std::getline(cin, sSelected);
//////////////////////////////////////////////////////////////////////////////////////
// RETRIEVE THE STRING THAT WAS SELECTED //
//////////////////////////////////////////////////////////////////////////////////////
va_list arguments2; // A place to store the list of arguments
va_start(arguments2, count); // Initializing arguments to store all values after count
//Main Lines of the output
for (int i = 1; i <= count; i++)
{
if (i == atoi(sSelected.c_str()))
{
return va_arg(arguments2, char *); // returns the string that was selected
}
else if (i != count)
{
va_arg(arguments2, char *);
}
else
{
va_arg(arguments2, char *);
}
}
va_end(arguments2);
//////////////////////////////////////////////////////////////////////////////////////
// MAKE PROVISIONS FOR IF THE SELECTION IS INCORRECT //
//////////////////////////////////////////////////////////////////////////////////////
cout << "\nERROR \nThe option that you have selected - " << sSelected << " - does not exist. Please try again. \n\n";
bValidSelection = 0;
} while (bValidSelection != 1);
}
All those coders who are working on the C++ based application and are stuck on c++ give options string can get a collection of related answers to their query. Programmers need to enter their query on c++ give options string related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c++ give options string for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of c++ give options string while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "c++ give options string". Visit this developer's friendly online web community, CodeProZone, and get your queries like c++ give options string resolved professionally and stay updated to the latest C++ updates.