Answer the question
In order to leave comments, you need to log in
How to implement optional input?
How to make an optional input?
#include <iostream>
using namespace std;
int a,c;
char b;
int main()
{
cout << "Input a:";
cin >> a;
cout << "Input b(optional):";
cin >> b;
cout << "Input c:";
cin >> c;
cout << a << " " << b << " " << c;
}
Answer the question
In order to leave comments, you need to log in
Through if
if (/*условие*/){
cout << "Input b(optional):";
cin >> b;
}
Creating an if for input b is correct, but not complete. It is necessary to define the command line arguments in main, then when an argument is specified on the command line, the condition inside the program will be executed. True C code :)
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
int opt_b = 0;
if (argc == 1) printf("No options\n");
if ((argc > 1) && (strcmp(argv[1],"b")==0)) {
opt_b = 1;
}
if (opt_b == 1) {
printf("Option b\n");
}
return 0;
}
.Myheader has a width of 100% and also has a 1px border.
The border is added to the total width of the box and you have a width of 100% + 2px
Add box-sizing: border-box;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question