- Strength to Increase Rep
- +15
- Strength to Decrease Rep
- -3
- Upvotes Received
- 2K
- Posts with Upvotes
- 2K
- Upvoting Members
- 538
- Downvotes Received
- 210
- Posts with Downvotes
- 194
- Downvoting Members
- 48
A common task in C or C++ is to get a string from somewhere and convert it to an integer. "Use `atoi`" is a common suggestion from the unwashed masses, and on the surface it works like a charm: #include <stdio.h> #include <stdlib.h> long long square(int value) { return value … | |
Re: > WRONG : Console.WriteLine("%d * %d = %d",c,a,b); Of course it's wrong, WriteLine() does not and never has purported to offer printf() style format specifiers. Saying that the above code is wrong is just like saying that the following line is wrong: Console.WriteLine("FORMAT INT #1 LITERAL(*) INT #2 LITERAL(=) INT … | |
Re: While there might be a tool out there to do the conversion, I wouldn't trust it. The appropriate way is to know both languages and convert manually. However, since assemblies written in either language are interoperable, there's no need to convert unless you're trying to match company standards where only … | |
Re: May I ask why you need to convert that code to C? Seems suspicious. | |
Re: I typically separate testing into two phases: 1. Unit testing for basic functionality and internal correctness that isn't easily checked by the end user or needs to be more thorough at a lower level. 2. UAT testing based on user stories from the design notes. These are cases where there's … | |
Re: Nobody is going to do your homework for you. But I'll give you a push in the right direction. You essentually have two options: 1. Build a new list in sorted order while traversing the old list. 2. Sort the old list into a new list. It's a fairly subtle … | |
Re: Take each number and subtract the mean, then square the result. Finally, divide by the length of the array and add that to your sum. The sum is the variance, and the square root of that is the standard deviation: double sd = 0; for (int i = 0; i … | |
Re: > so those who love banners can enjoy them. Spoken like someone who doesn't depend on ad revenue to stay in business. Hop in chat sometime and ask Dani to explain where Daniweb's funding comes from. She'll talk your ear off, but it's an eye opener. | |
Re: [QUOTE]1) Why I want to delete? I want to delete my account because I've never used Daniweb, so it's useless for me. ... Note that I'm registered since 2009 and rarely (2 times) I came on Daniweb to find answers (sorry but it's the true)[/QUOTE] What's wrong with simply abandoning … | |
Re: > To me, the best type of SEO is popularity. The more popular your site is, the higher ranked you would be (based on backlinks, etc). Indeed. But you're neglecting the critical first step that to become popular you must be noticed. How do you get noticed when your site … | |
Re: This seems more like a job for a frequency list. You can use a dictionary of characters and counts like so: for each word in the dictionary build a frequency list of each character initialized to 0 for each character in the letter collection if the character exists in the … | |
Re: > OKAY YOU NOOBS!!!!! > HERE IS A MUCH SIMPLER THING TO DO!!!! It's also [subtly broken](http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx) if you care about uniform distribution. Simple isn't always better...noob. ;) | |
Re: > Create a TcpClient and connect to the POP3 server, open a NetworkStream that uses the client and download all the data available. You can then parse this using the POP3 specification. That's a gross oversimplification. ;) Doing it right is a non-trivial task, so I'd recommend utilizing a library … | |
Re: While I'd start by suggesting that you use the .NET file stream options instead, String^ *can* be converted to std::string using marshal_as if so needed. | |
Re: The trick with this program is defining what's meant by a "word". You can't just take whatever is separated by whitespace and call it good, because that will incorrectly include punctuation. To properly do it would require some lookahead and lookbehind, and even then poorly formatted sentences could cause an … | |
Re: From the provided code, I can't offer more than int delete_list_entry(temp_head, randvar); should be delete_list_entry(temp_head, randvar); I get the impression there's a little confusion between how to declare/define functions and how to call them. Also, if `delete_list_entry` returns a value, I'd also ask why you're ignoring it. | |
Re: > It could be the Framework or it could be how it has been implemented by my predecessor It's the latter, almost surely. The Entity Framework most certainly has its quirks, but being unstable and slow are not among them when used properly. > So I'm wondering if there is … | |
Re: `p` is a pointer to read-only memory. While some compilers might allow it to be modified, technically what you're doing is undefined behavior. Change line 6 to `char p[] = "foo";` and it should work just fine. | |
Re: > I’ve realized that I’m a little weak when it comes to fix, modify and understand code within large applications, and, needless to say, I need to find a way to get better at it. There are two books I rather like: Code Reading and Code Quality. They go beyond … | |
Re: I'm surprised that nobody has even mentioned the TextFieldParser class in Microsoft.VisualBasic.FileIO... :P | |
Re: What have you done so far? Nobody here will write this for you. | |
Re: I'm a bit surprised you haven't been walking around town handing them out as advertising. There were still a number of big boxes full of shirts after that night, IIRC. ;) | |
Re: > Teaching Pascal as a first language in 2017? Really? Pascal has the benefit of being very easy to understand. It's also hand-holdey, which for most of us translates to "heavily restricted", but for beginners means less working around the quirks of the language and focusing directly on solving the … | |
Re: This is clearly a homework or interview question, so please let us know what your thoughts are first. | |
Re: > Also if the time xomplexity of both the methods is O(n), then how is the second method runs faster than the linear search method? Big O only tells you the expected growth rate of the algorithm, which in both cases is indeed O(n), not its actual execution performance. Algorithms … | |
Re: > This is really confusing as I dont know which is right and which is wrong, could use some help They're both right. Your compiler is right because it's from 1991 and conformed to the C++ of the time. Your book is also right because it's reasonably current with the … | |
Re: > I do not understand why did you make 3 for loops? The real question would be why did the OP not format his code in an understandable way. Reread the original code, it doesn't have three nested loops. | |
Re: > char array's are actually pointers This is a common misconception. An array is *not* a pointer, but when used in value context, the name of an array is converted to a pointer to the first element in the array. In object context, the name of an array is not … |