[Solved] memory leak in c++ and how to fix it

The “best”™ solution is to not use pointers at all, as then there’s no dynamic allocation that you can forget to delete. For your case it includes a few rather minor changes to make it work. First of all I recommend you create a Song constructor taking all needed values as arguments, then it becomes … Read more

[Solved] Why pointer is not NULL after using delete in C++

It’s because when you say delete p you’re deleting a pointer to memory which completely erases the reference to the new memory you allocated. When you say if p==NULL you’re checking to see if the pointer was set to null when in fact the memory that it was pointing to was de-allocated so the pointer … Read more

[Solved] When do you use the & operator in C language?

Generally, you use just the name of an object, like i, when you want its value. In printf(“%d “, i), we want printf to print the value of i, so we just pass i. In scanf(“%d”, …), we do not want to tell scanf what the value of i is. We want scanf to change … Read more

[Solved] vector push_back add new items

You’re pushing five pointers to the same array into your vector, so when you print the contents of the array pointed to by each pointer they’re all the same. You only have a single array: txt. Each time through your loop, you write new contents into that array and push a pointer to it into … Read more

[Solved] Console app or web app

you can create C# console app which will be installed on server and provide back end functionality. But you can also do this with web app. Third there is “WPF” concept which changes the web layout to desktop/console application. 1 solved Console app or web app

[Solved] extracting specific format elements from the list in c#

var abc = new List<string> { “abc”, “123”, “abd12” }; var alphaXorNumerical = abc.Where(str => str.All(Char.IsDigit) || str.All(Char.IsLetter)); var others = abc.Except(alphaXorNumerical); If you also want to check for whitespace, use this instead: var alphaXorNumerical = abc .Where(str => str.All(Char.IsDigit) || str.All(ch => Char.IsLetter(ch) || Char.IsWhiteSpace(ch))); 11 solved extracting specific format elements from the list … Read more

[Solved] Cannot convert char to char

The error is on this line: key[j]=words[index]; key is a std::string key; Therefore, key[j] is a char. words is a std::vector<std::string> words; Therefore, words[index] is a std::string. You cannot assign a std::string to a char. C++ doesn’t work this way. Your code is equivalent to the following: char a; std::string b; a=b; It is not … Read more

[Solved] “Not all code paths return a value”

Are you trying to return the integer array score? …. for (int i = 0; i < score.Length; i++) { total += score[i]; } return score; } So you can capture this array when you call it like so int[] scores = GetValues(); 5 solved “Not all code paths return a value”

[Solved] Unable to access property in C# in Main() [closed]

Your code has two problems. One, SSN must be static if your going to use it in the Main method. Two, Console.WriteLine(“{0},SSN”) should be Console.WriteLine(“{0}”, SSN). namespace ConsoleApplication6 { class Program { public static string SSN { get; set; } // Return a hash code based on a point of unique string data. public override … Read more