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

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 use … Read more

[Solved] Why sort() function causes compilation error when it is used for set of class objects

Two problems. First, you cannot reorder the elements of a set. Their ordering criteria is determined upon construction, it is a fundamental part of the object. This is necessary in order for it to achieve O(log n) lookups, insertions, and deletions, which is part of the promises of std::set. By default, it will use std::less<Edge>, … Read more

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

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 code, … Read more

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

(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); // etc. … Read more

[Solved] How to implement currency conversion

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 rate; … Read more

[Solved] Trying to calculate age in C

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 variables … Read more

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

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 Tableau<T>::remove(size_t … Read more