[Solved] How to handle an exception without closing application? [closed]

[ad_1] How I went about in solving my issue: bool success = false; try { //try to send the message smtpmail.Send(message); success = true;//everything is good } catch (Exception err) { //error with sending the message errorMsg.Text = (“Unable to send mail at this time. Please try again later.”); //log the error errorLog.Log(err); //note errorLog … Read more

[Solved] Computing the overtimepay is my formula correct?

[ad_1] Your calculation is alright (not that complicated after all!), I’d just suggest to change your condition statement to reduce a bit your code: double hours, overtimepay, wage; printf(“Enter number of hours: “) scanf(“%f”,&hours); wage=9.73*hours; wage = 9.73 * hours; printf(“Your wage is: %f\n”,wage); if(hours > 40) { overtimepay = (9.73*(hours-40))*1.5; printf(“Your overtime pay is: … Read more

[Solved] missing binary operator before token “(“

[ad_1] You misspelled defined: #if definied(_WIN32) || definied(_WIN64) || definied(__WIN32__) #elif definied(__linux) || definied(__linux__) || definied(linux) should be: #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) #elif defined(__linux) || defined(__linux__) || defined(linux) [ad_2] solved missing binary operator before token “(”

[Solved] input in C programming language

[ad_1] The value have only 2 decimal places is a matter of displaying it, so you just need to print the number of decimal places you are interested in, like float value = 123.123456; printf(“%.2f\n”, value); if you want to dynamicaly specify that number, you can use float value = 123.123456; int decimals = 2; … Read more

[Solved] Does there exist an algorithm for iterating through all strings that conform to a particular regex?

[ad_1] Let’s say the domain is as following String domain[] = { a, b, .., z, A, B, .. Z, 0, 1, 2, .. 9 }; Let’s say the password size is 8 ArrayList allCombinations = getAllPossibleStrings2(domain,8); This is going to generate SIZE(domain) * LENGTH number of combinations, which is in this example (26+26+10)^8 = … Read more

[Solved] C++ : Handling input

[ad_1] There is no need to check the value of d in the while condition if you have the break in each valid case: while (true) { cout << “1.Easy\n”; cout << “2.Medium\n”; cout << “3.Hard\n”; cout << “Choose your difficulty:”; cin >> d; if (d == ‘1’) { a.setdifficulty(“Easy”); break; } else if (d … Read more

[Solved] Why does this need auto? [closed]

[ad_1] Because the type isn’t char. The type is char(*)[640][3] and the declaration would be written as char (*data)[640][3] = new char[480][640][3](); 1 [ad_2] solved Why does this need auto? [closed]

[Solved] “Method must have a return type” [closed]

[ad_1] It means that you’r Send method does not have a return type. Meaning that you don’t return anything in that method. If that method shouldn’t return anything, then just add void as a return type: public void Send(SerialPort serialPort1) { if (serialPort1.IsOpen) { var content = new List<byte>(); content.Add(2); content.AddRange(Encoding.ASCII.GetBytes(CommandText)); content.Add(3); byte[] buffer = … Read more

[Solved] I want to know the count of each item in a list

[ad_1] You can use GroupBy: var voteGroups = Votes.GroupBy(s => s); Now, if you want to know the count of each string use Enumerable.Count: foreach(var voteGroup in voteGroups) Console.WriteLine(“Vote:{0} Count:{1}”, voteGroup.Key, voteGroup.Count()); Another way is using ToLookup: var voteLookup = Votes.ToLookup(s => s); foreach (var voteGroup in voteLookup) Console.WriteLine(“Vote:{0} Count:{1}”, voteGroup.Key, voteGroup.Count()); The lookup has … Read more