deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The VisualBasic namespace has a lot of cool stuff that really shouldn't be there because it's too well hidden. FileLogTraceListener comes immediately to mind as I've been using it a lot lately.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Print out search and you'll see what the problem is. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster
  1. Read the documentation
  2. ???
  3. Profit

I've written too many CSV parsers (real ones, not this naive comma split stuff) to be interested in doing it again. ;)

ddanbe commented: Great! +15
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Can I get an example regarding how to declare it and then initialize it to NULL

Sure, once you answer my question. I can't tell you how to use some random class that I'm not familiar with, but given either the class itself or sufficient documentation I'll be happy to help out.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Isn't there a way to check an array is initialzed by any values(int, double).

Not without some scaffolding in place to help. Consider an array of int. Regardless of whether the array is initialized or not, all elements contain an integer value. The difference is that an an uninitialized array those values are meaningless to you. Unless your compiler helpfully initializes all data with something predictable you can test against (not a safe assumption), there's no way to check for an uninitialized variable given only that variable.

You might consider wrapping your array in a class that includes that scaffolding or ensures that the array is always initialized.

p.s. It's technically undefined behavior to read an uninitialized variable's value. So even if your compiler gives you predictable defaults, your code isn't portable.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

counted_ptr isn't a standard class, which means you're trying to use a third party class. Where did you get it? How you use it greatly depends on how it was written to be used.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Deploying a database can be tricky as well, even though it's straightforward to require that a database server be present for the application to work. In the past I've used three different deployment methods:

  1. Build the database locally and provide a backup file that can be restored at the deployment site.
  2. Provide scripts that will automatically create tables, indexes, and initial data.
  3. Use the Entity Framework to create and update database schemas.

I overwhelmingly prefer #3, but there's a bit of a learning curve for the Entity Framework. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I wish you the best of luck, but strongly suspect that it won't end well one way or another.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Cheating is a huge problem, and I understand it's not your problem, but you should reconsider your policies to help prevent it

Our policies already prevent the cheating that we can control. For the cheating we cannot control, school policies and disciplinary measures can easily take over without us deleting content.

Honestly, I'm somewhat confused as to what this teacher is trying to accomplish by having us destroy evidence.

Other websites I've contacted in the past were able to, and did, delete the content immediately

It's impossible to cater to the policies of every school and still be a useful resource for students, so we don't. Very simple.

JeffGrigg commented: Yes; exactly. +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is id your primary key?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's a different assembly entirely from System.Web. System.Web.Extensions was added with 3.5, and the error says that you're trying to reference the 4.0 version. If your project is targeting 3.5 yet trying to reference 4.0 assemblies, that alone could be the issue.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Do you have an example of what you're having trouble converting? A sepcific case makes it easier to clarify things for you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I suspect it's becuse you're not wrapping the date string in single quotes. MySQL allows you to do that with any type, so it might be a good idea to just do it unconditionally:

Dim sql As String = "INSERT INTO tblmysq(id,name,branch,sex,dat)VALUES('" + TextBox3.Text + "','" & TextBox1.Text & "','" & TextBox2.Text & "','" & ComboBox1.SelectedItem & "','" + Format(DateTimePicker1.Value, "yyyy-MM-dd") + "')"
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So when does one actually start to affect reputation points?

When your profile lists power to affect other members' reputation underneath your rep points.

Does skill endorsements have to do anything with reputation points?

No.

Maybe I will be stuck with -1 reputation point for a long time from now. Hehehe ;)

Maybe. It's impossible to predict whether someone will simply vote or choose to add rep. But if you make a lot of high quality posts, it's not unreasonable to expect positive rep at some point.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's MSSQL syntax. MySQL uses back ticks around column names instead of brackets:

"INSERT INTO tblmysq(name,branch,sex,`dat`)VALUES...
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Just to clarify, you mean that if you up voted a post with comment it would be considered as a reputation point but if I up vote a post with a comment it would not affect the reputation points?

Correct. With negative reputation points, your power to affect another member's rep is 0.

Actually its the reputation points that is shown next to the username while viewing the forums.

Solid point. Though there's a balancing act between showing useful information (which reputation is) and potentially showing so much information that it clutters up the view (such as if we added post quality score).

However, votes seem to be currently more popular than reputation, so perhaps we should show the post quality score instead of reputation. There are many options, unfortunately, and none of them will make everybody happy. ;)

Maybe we should not let the reputation points go under 0?

That would only benefit low quality posters and this very specific case that gets resolved over time as you attract positive reputation with high quality posts.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

One of the reasons votes don't contribute to reputation is for the folks who have strong rep power to apply a mildly negative opinion without the risk of decimating another's rep. We could have implemented a way to choose how many point are applied, but that makes things more complicated and more confusing overall. Another reason is for folks who don't have strong rep power being on equal footing with those who do. It's an even playing field.

After diddling with the rep power calculations for ages, it was ultimately decided that the voting mechanic was also important and that it should be somewhat separate from reputation.

While the mechanic is combined, votes and reputation are indeed separate concepts with separate metrics in your profile. Reputation also happens to apply a vote because that only makes sense, but honestly that fell out of the implementation more than anything. ;)

My first question would be that if votes count toward reputation, what's the point of having both? Do you feel that one of them is unnecessary? That's not a rhetorical question either, feedback on how things are done is valuable for evolving the site into something that works well for everyone.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Guys .. u thought that I never tried .. I tried alot.

Prove it. Not only does it show us that you're not just looking for a handout, but it also helps us to determine your level for tailoring help to you. Further, instead of a lot of back and forth, you might find that your problems are actually easy to fix when someone more experienced has a look at the code you have.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

My opinion is that you can never, ever have too many program comments or step comments and a program with too many comments is much easier to debug, use, understand and share than one with not enough comments.

I strongly disagree. Excessive useless comments can be even worse than no comments.

it would help him to have too many rather than too few comments to explain the code; right?

That's fine, provided it's clear that the unusually verbose comments are being used to help a beginner understand things that would be obvious to everyone else.

Anyway, if you don't think comments are good then that is a great opinion for you

Way to completely misinterpret what I said. I love comments, they're awesome. But there's a condition that the comments must actually be helpful when reading code. For example:

void hello() // function called hello that returns void
{
    cout << "Hello, world!\n";
} // End foo

Both comments are unnecessary. The first just says what anyone with even a passing knowledge of C++ would know from glancing at the code, and the second is so close to the start of the function that the purpose of an end marker is completely defeated.

I don't believe that such a thing exists as a program with too many comments.

I've had to maintain code bases with too many comments. "Too many" meaning all kinds of comments that are utterly useless for …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The first thing that I would suggest is for you to use some comments stating what everything is and what is is supposed to do and maybe some pre and post condition statements around the class methods.

Note that your sample class is a fine example of how not to comment. Comments supplement the code to answer questions a reader might have like why?. Comments shouldn't simply repeat what the code clearly says, but a plain English comment of obtuse code that cannot be simplified for one reason or another (hey, that's another comment!) are acceptable.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If you can connect to the web at all, it's completely open from the perspective of the Wi-Fi. Locking down access to specific pages or domains is the job of the firewall/router.

To find out what's blacklisted or whitelisted, I think you would need administrative access to the firewall and router. Otherwise it's just trial and error to see what the network allows.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Can you post an example of the situation you're asking about?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Two things to consider:

  1. Make sure your project targets the full framework and not the client profile.
  2. System.Web wasn't updated with .NET 3.5. You'll still find it in the 2.0 framework folders.
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
if (condition that evaluates to boolean)
{
    // The condition was true
}
else
{
    // The condition was false
}
Assembly Guy commented: Nice :P +5
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm having trouble trying to grasp pseudocode.

It makes more sense when you realize that pseudocode has no rules. It's not going to be executed, so there's no compiler to satisfy. Just write something that makes sense to you and is consistent.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Pseudocode has no standard definition, just make something up. It could be as free form as:

declare an array of 20 integers

Or more rigid like an actual programming language:

 declare array(20) of integer
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm not sure I understand the question. Can you rephrase it?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The linked list is a storage mechanism. Wherever you're currently printing, add to the list instead. Then you have the data in memory and can print it later at your leisure.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

On the surface it seems enticing, but the concept of immortality (or extreme longevity in this case) is usually more about fear of death than anything. If you really think about it, living so long would be more of a curse than a blessing. I suspect most people who took such a pill would end up suiciding long before reaching the age limit.

Reverend Jim commented: I couldn't agree more. +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

n is typically represented as a collection of items being processed by the algorithm because that's easy to visualize. For example, if you have an array of 10 items, replace n with 10 for a specific calculation.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Nice. You might also consider including goto-based equivalents for each loop to really nail down the underlying logic.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It sounds almost like you're working with a client-server setup. The client takes ticket requests and sends them to the server, then the server responds by creating a ticket and returning the result?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

How exactly do I use the linked lists to turn two characters on either 'side' of the colon into integers?

The linked list would store your records, not perform any transformations on them. So you'd extract the data, format it however you want, then store it in a linked list (or array if you'd like) for later printing.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I do know PHP, but the content and structure of the shared data is largely irrelevant in this case. What you want to look at are IPC (interprocess communication) techniques. It could be as simple as dropping a serialized file from one process that the other reads or as much as direct communication between two processes using sockets or pipes.

Which option is best very much depends on what these programs do, where they run, and how the data will be used.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Did you also delete your cookies and temporary files?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

All modern compilers will require the int return type unless (in some cases) you tell the compiler you are building legacy (old) code. The old K&R compilers would allow void return type for main(), but no longer (by default).

You're thinking about implicit int, I suspect. This is no longer supported as of C99:

main()
{
    return 0;
}

The int return type is still there, it's just implied. One problem with this feature is that people would assume that no return type meant no return statement was required, which isn't the case.

Support of void as a return type from main is completely a compiler extension and always has been. Even K&R C specified main as returning int.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I have mix up pointers and by reference.

"By reference" in C is "by pointer". That's how you simulate pass by reference because there's not an actual reference type available. Pointers are close enough though, and colliquially we simply say that you're passing by reference instead of passing by simulated reference using a pointer. ;)

Can you help me to understand why void main() wouldn't work?

The only two signatures of main that the C standard specifies as universally correct are:

int main(void)
int main(int argc, char *argv[]);

Equivalent parts like char **argv and different names for the parameters are acceptable as well.

Returning void from main is only supported by a subset of compilers, and if the compiler you're using doesn't support it, using void main invokes undefined behavior. Undefined behavior is among the worst possible results for a program because it removes all predictability.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The actual error is that you're adding an unnecessary level of indirection in the tokenise call. tokens is already an array of pointers, there's no need for the address-of operator.

However, that said you still have issues in the program. Most notable is the next line tries to print tokens as a single string when it's really an array of strings. You need to loop over the array and print each string individually. Further, tokenise should return the number of tokens so that you know when to stop the loop.

Compare and contrast, I fixed other minor issues like including string.h and not using void main:

#include <stdio.h>
#include <string.h>

#define MAX_NUM_TOKENS  100

int tokenise(char inputLine[], char * tokens[]);

int main(void)
{
    char inputLine[] = "Testing program Testing program";
    char *tokens[MAX_NUM_TOKENS];
    int n = tokenise(inputLine, tokens);
    int i;

    for (i = 0; i < n; i++) {
        printf("token: %s\n", tokens[i]);
    }

    return 0;
}

int tokenise(char inputLine[], char * tokens[])
{
    int i = 0;
    char *pch;

    pch = strtok(inputLine, " ");

    while (pch != NULL)
    {
        tokens[i] = pch;
        i++;
        pch = strtok(NULL, " ");
    }

    return i;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Set the IsMdiContainer property to True on your parent form.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You have a number of options, but it depends what these programs are and do. Can you elaborate a little bit?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Good luck. Feel free to ask a specific question if you encounter any issues writing your program.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It's like 3000 lines of code!

I only see 383 lines. Anyway, when I originally asked for code, I made sure to ask for a small but complete program that exhibits the problem. Some modicum of effort is required on your part to pare down the program to bare essentials so that it's easier to help you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

For NP hard problems is it proved that there no algorithms that can solve this problem in polynomial time?

Not yet, no.

For NP complete problems there have not yet been algorithms that can solve this problems in polynomial time but you cannot completely rule out the possibility.

If the NP-complete problem is solved, all subsets will be solved as well, including NP-hard.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

No programmer in his/her right mind would write that big of program without using functions to make it more readable.

To be fair, it would be drastically shorter without all of the Turbo C++isms. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I think setting an arbitrary number of tests is silly. If you can get away with one test case, that's fine. If you require hundreds to properly ensure correctness then so be it. The number of test cases should be determined based on what you're testing, why you're testing it, and how detailed you want the results to be.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

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 a clear input and output for the end user.
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

so is it correct to say that IN can not be necessarily used as a replacement from Exists, or reverse ?

in can be used as a replacement for exists in terms of functionality (may ways to do the same thing, of course). But if the result set of the subquery is large, exists will be quite a bit faster since it's essentially taking a count that stops when a single match is found. in will typically be faster when the result set is small.

returns all records form Customers table. Why ?

Because the subquery isn't keyed on the specific customer. You can think of these simple queries as an imperative foreach (not a perfect equivalence, but helps to visualize):

a = empty recordset

foreach customer in customers
    b = empty resultset

    foreach product in products
        if product["prodCategory"] = 'Consumer electronics'
            b = b + product

    if b <> empty
        a = a + customer

Notice that the inner loop doesn't look at the current customer record at all to determine its result set, so unless the table is empty, b will always contain at least one record, and the exists test will always evaluate to true. Therefore you'll always select every customer in the customers table.

Now consider the same equivalence using the customer ID:

a = empty recordset

foreach customer in customers
    b = empty resultset

    foreach product in products
        if product["prodCategory"] = 'Consumer electronics' AND product["cus_id"] = customer["cus_id"]
            b …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Required watching for P and NP: https://www.youtube.com/watch?v=msp2y_Y5MLE

deceptikon 1,790 Code Sniper Team Colleague Featured Poster