Administrator Featured
Member Avatar
Featured deceptikon 1,790 Replied To a Post in Code Snippet Hexagon window
Topic by ddanbe in Software Development
Moved to code snippets. :) Reply by deceptikon
Member Avatar
Featured deceptikon 1,790 Edited Code Snippet Hexagon window
Yes, WPF. The learning curve is steep, but what amazing things you can do with it!
Look at this hexagon window for instance. Serves no purpose in a business environment I guess, but in a gaming situation it could work. For me, it was just fun to get this up … Topic by ddanbe in Software Development
Member Avatar
Topic by Nether_1 in Software Development
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. Reply by deceptikon
Member Avatar
deceptikon 1,790 Replied To a Post in randvar error
Topic by chris ig in Software Development
c++
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. Reply by deceptikon
Member Avatar
Topic by Devon_4 in Software Development
c++
`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. Reply by deceptikon
Member Avatar
Featured deceptikon 1,790 Replied To a Post in Advices to become a better developer
Topic by Violet_82 in Software Development
> 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 … Reply by deceptikon
Member Avatar
deceptikon 1,790 Replied To a Post in How to read csv file contents in VB.Net
Topic by MukeshZ in Software Development
I'm surprised that nobody has even mentioned the TextFieldParser class in Microsoft.VisualBasic.FileIO... :P Reply by deceptikon
Member Avatar
deceptikon 1,790 Replied To a Post in need help with this school project
Topic by Quinton_1 in Software Development
c++
Okay. Reply by deceptikon
Member Avatar
deceptikon 1,790 Replied To a Post in ATM machine
Topic by azeez_2 in Software Development
c++
What have you done so far? Nobody here will write this for you. Reply by deceptikon
Member Avatar
Featured deceptikon 1,790 Replied To a Post in Merchandising
Topic by ddanbe in Community Center
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. ;) Reply by deceptikon
Member Avatar
Featured deceptikon 1,790 Replied To a Post in Brainf**k
Topic by AssertNull in Programming
> 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 … Reply by deceptikon
Member Avatar
deceptikon 1,790 Replied To a Post in C code snippet
Topic by Prasad_4 in Software Development
c
This is clearly a homework or interview question, so please let us know what your thoughts are first. Reply by deceptikon
Member Avatar
Hello ladies and gents, i hope you are all well! Just recently joined this site looks great and easy to use.

I am just getting into php and msql i have managed to create a table that spits out the data but i am looking for a really simple way … Topic by Tony_20 in Web Development
Member Avatar
deceptikon 1,790 Replied To a Post in User Input Char Array?
Topic by daino in Software Development
c++
> 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 … Reply by deceptikon
Member Avatar
deceptikon 1,790 Replied To a Post in Is there a way to detect garbage value?
Topic by MRehanQadri in Software Development
c++
> is there any pattern to find out garbage value????????

The term "garbage" is meaningless without context. What's garbage for one program could be perfectly valid for another program. So step 1 is to clearly and unambiguously define what garbage means to your program. Once that's done, you can absolutely … Reply by deceptikon
Member Avatar
deceptikon 1,790 Replied To a Post in Bucket Sort
Topic by Dhelandel in Programming
Most common domain applications, perhaps? Which examples are you referring to? Bucket sort is certainly not limited to that range, though I can imagine how it's wildly useful. Reply by deceptikon
Member Avatar
Topic by nttthuy in Web Development
Step 1 of troubleshooting is narrowing down the places you need to look. With that in mind, my first question would be whether `dt` actually contains data or not when you look at it in a debug trace.

If it does, then binding or refreshing the grid would be my … Reply by deceptikon
Member Avatar
Featured deceptikon 1,790 Replied To a Post in Help with sum of Even or Odds Array
Topic by Brian_22 in Software Development
> zachattack05 : 25 % 2 would return 5

I'm so tempted to write a proof where this actually happens. :D Reply by deceptikon
Member Avatar
Featured deceptikon 1,790 Replied To a Post in Help with sum of Even or Odds Array
Topic by Brian_22 in Software Development
> ... or use bitwise operator `if(i&1)` if true even else odd.

I suppose if you want readers of your code to think you're clever, or have legitimately profiled the code for performance, run all practical test cases, and determined that this micro-optimization is warranted *and* not actively harmful.

> … Reply by deceptikon
Member Avatar
deceptikon 1,790 Replied To a Post in Empty path name is not legal
Topic by Baastina in Software Development
Well, assuming the title of your thread is the problem, I'd ask what `a.FileName` is and contains. An empty string is indeed not a legal file path, so you want to make sure that `a.FileName` represents a valid file that exists.

Most likely there's a flaw in the UI's design … Reply by deceptikon
Member Avatar
Featured deceptikon 1,790 Replied To a Post in Type conversion from string to const char * problem
Topic by nitin1 in Software Development
> Thus c_str() isn't making a copy of anything, globalPtr is pointing to the same array of characters that abc uses and if you make a change using globalPtr or abc, both are affected.

Yup, `c_str` isn't required to make a copy of anything, and usually doesn't.

> returnValue seems … Reply by deceptikon
Member Avatar
Topic by Bryan_5 in Software Development
Let's start by fixing things so the code doesn't break massively from out of range errors:

#include <iostream>
#include <string>

using namespace std;

typedef int* intPtr;

const int MAX = 100;

void printArray(intPtr total, int size)
{
for (int i = 0; i < size; i++)
cout << *(total + … Reply by deceptikon
Member Avatar
Topic by Bryan_5 in Software Development
> `while (*p != '\0' || *q != '\0')`

This is a red flag. Your arrays are not constructed as C-style strings, so '\0' isn't likely to exist within your owned memory. You can make that happen by adding the terminating value at the end of the arrays:

intArray = … Reply by deceptikon
Member Avatar
Featured deceptikon 1,790 Replied To a Post in Type conversion from string to const char * problem
Topic by nitin1 in Software Development
> when fun() returns, it calls the copy constructor again, right?

Ehh, kind of. Return value optimization is a thing, but conceptually it's okay to think of things that way for simplicity.

> But, won't it call the copy constructor and then make the copy of the object and return … Reply by deceptikon
Member Avatar
Featured deceptikon 1,790 Replied To a Post in Type conversion from string to const char * problem
Topic by nitin1 in Software Development
> Can you please explain the reason behind this?

You're capturing a direct pointer to the internal storage of the string returned by fun(), which is a temporary object. The temporary object is subsequently deconstructed, and the internal storage goes away. I'd suggest stepping into everything in the debugger to … Reply by deceptikon
Member Avatar
Featured deceptikon 1,790 Replied To a Post in Boilerplate for publishing code on Daniweb
Topic by JamesCherrill in Community Center
> I know that Daniweb owns the I.P.

No. That was unfortunate wording in previous terms of service, and the intention was to absolve Daniweb of legal responsibility for storing and editing the content of posts. After a quick reading, it looks like the wording was changed.

> I want … Reply by deceptikon
Member Avatar
Topic by something_1 in Programming
c++
I'd strongly recommend walking through your code with a debugger. And my big hint for the problem is that the Enter key places a character in the input stream: '\n'. When you mix formatted and unformatted input (eg. getline and the >> operator), there's a strong chance that newlines are … Reply by deceptikon
Member Avatar
deceptikon 1,790 Replied To a Post in Short data type
Topic by sunshine102030 in Computer Science
c++
> I know that the max value for short data type is 32767

Not necessarily. The C++ standard defines a minimum required range, but compilers are free to make it larger.

> but the question is from where we get this number -25536 ?

First I'll note that it's not … Reply by deceptikon
Member Avatar
Topic by catastrophe2 in Programming
It's not necessary, but generally recommended for classes that implement IDisposable. Reply by deceptikon
Member Avatar
Topic by catastrophe2 in Programming
Well, for starters the "/* ... */" comment supports multi-line, so you'll need to consider that in your parsing. A simple approach would be a loop that reads and throws away characters until the closing token is found:

public static void processInput(StreamReader input, StreamWriter output)
{
int ch;

while (!input.EndOfStream) … Reply by deceptikon