0

Im not able to print with this serial no "318-356-082" with below code.Please can any one tell this Answer where I did the mista

/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include<iostream> #include<algorithm> using namespace std; int main() { // Comparing ASCII values of a and b cout << "Hi" <<std::max(0,2) << "\n"; std::string device; bool filter= true; device = "V240m B-FF 318-356-082"; if((filter == true) && !device.empty()) { const char snLength = 11 ; // xxx-xxx-xxx char sn[1 + snLength] = { 0 }; cout<< device <<endl; const char* const snFormat = "%3u-%3u-%3d"; int b1, b2, b3; for(int i = 0; i <= std::max(0, (int)device.size() - snLength); i++) { if(!isdigit(device[i])) continue; if( sscanf( device.substr(i, snLength).c_str(), snFormat, &b1, &b2, &b3) < 3) continue; sprintf(sn, snFormat, b1, b2, b3); device= sn; cout<< device <<endl; break; } //if(!sn[0]) continue; } else { cout<<"Faile"<<endl; } // Returns the first one if both the numbers // are same // cout << std::max(7,7); return 0; }

6th Aug 2020, 4:26 AM
M Ashok Kumar
M Ashok Kumar - avatar
1 Resposta
+ 1
Can you explain what the program was supposed to do? And I suggest to share a saved code link instead of raw text like this. Code links makes analysis bit easier to do, no need for copy/paste over and over. Follow the below guide to share link 👇 https://www.sololearn.com/post/75089/?ref=app
6th Aug 2020, 4:43 AM
Ipang