[Solved] confusing notation in C++ (OMNeT++)

[ad_1] Let us assume that msg->dup() returned void * — that is, a pointer to void, which means a pointer whose type the compiler doesn’t track. But you may know, e.g. because of documentation on that function, or because certain preconditions have been met, that msg->dup() will return a pointer to CMessage. Before you can … Read more

[Solved] How will C parse this sentence? [closed]

[ad_1] It is parsed as: b = (a++)++ + a; This is an invalid expression. The increment operator can’t be applied twice as (a++) isn’t an lvalue. The tokenizer isn’t context-aware and will match the longest token possible, so it is not parsed as the syntactically valid a++ + ++a. (That still would be invalid … Read more

[Solved] Encrypting the password using salt in c# [closed]

[ad_1] (As suggested, I’ve replaced my previous salt generation method with something that should be more secure) To generate a random salt: public static string GenerateRandomSalt(RNGCryptoServiceProvider rng, int size) { var bytes = new Byte[size]; rng.GetBytes(bytes); return Convert.ToBase64String(bytes); } var rng = new RNGCryptoServiceProvider(); var salt1 = GenerateRandomSalt(rng, 16); var salt2 = GenerateRandomSalt(rng, 16); // … Read more

[Solved] How to implement currency conversion

[ad_1] Please change you code with below code [WebMethod] public decimal ConvertGOOG(decimal amount, string fromCurrency, string toCurrency) { WebClient web = new WebClient(); string apiURL = String.Format(“http://finance.google.com/finance/converter?a={0}&from={1}&to={2}”, amount, fromCurrency.ToUpper(), toCurrency.ToUpper()); string response = web.DownloadString(apiURL); var split = response.Split((new string[] { “<span class=bld>” }), StringSplitOptions.None); var value = split[1].Split(‘ ‘)[0]; decimal rate = decimal.Parse(value, CultureInfo.InvariantCulture); return … Read more

[Solved] Trying to calculate age in C

[ad_1] Expressions in C are not formulas. This: int age = CurrentYear – BornYear; Does not mean that the value of age will always be CurrentYear – BornYear. It means that at that point in the code, age is set to CurrentYear – BornYear based on the current value of those variables. Both of those … Read more

[Solved] how can I delete the elements of array after read it in C++?

[ad_1] A couple of killers in the Tableau::delete method: The function will not compile because of the use of the delete keyword as the function’s name elements[index+1] will allow reading elements[nbElements] Which may or may not be out of the array’s bounds, but is certainly one more than intended. Try instead: template <class T> void … Read more