deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Are ProjectConstants::CONSTANT1 and ProjectConstants::CONSTANT2 declared in the global namespace or not?

A using declaration introduces names to the current namespace, so in this case yes, they are indeed in the global namespace for that particular translation unit.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Compare this with your code and see if you can figure out why I made certain changes:

for (char *i = beach; *i != '\0'; ++i)
{
    if( *i >= 'a' && *i <= 'z')
        *i -= 'a' - 'A';
}

You've inspired me to do a pony avatar ha ha

Welcome to the herd. :D

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

A character literal uses single quotes, string literals use double quotes. There's a difference, and it's rather significant. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

localhost or not, the machine must have a mail server installed and running or SMTP simply won't work.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but what does my output need to be.

According to the requirements you posted, output is not specified. Do what you want, or output nothing at all.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

For a beginner, what would you suggest I start with?

You can search google for a general overview on different programming languages as well as high level comparisons. I'd strongly recommend picking the language that interests you most, because you'll be more likely to stick with it. However, with that said, Python is a friendly language for beginners.

And are there any internet resources you could recommend as well?

Google and a lot of skepticism. It's surprisingly educational when you have resources with a wide range of quality and need to weed out the crap.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If one was to get into college for computer science, what other general classes do you believe would be helpful in that area, if any?

I'd suggest brushing up on algebra, linear algebra, and formal logic. Higher math helps but isn't required since it really only helps for nailing down certain concepts (like recursion) and proofs. It also couldn't hurt to do research on data structures and algorithms, because a lot of the CS course will stem of that stuff. Finally, a 10,000 foot view of how computers and communications work under the hood will help immensely. You don't need to understand everything about TCP/IP or exactly how a CPU works, for example, but you should have a rough understanding of the basics.

And I apologize if I came across as hostile.

By hostile I mean either intentionally or unintentionally (unintentionally, in your case) forcing us to work harder to help you. It doesn't mean I think you have a bad attitude or anything.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Broad it was meant to be

I have some criticism for you. :) Specific questions get good answers. Broad questions go unanswered or attract flames. If you're asking for help, it's unproductive to be actively hostile in making it easy for others to help you.

I am interested in learning everything and anything about computers.

I'm interested in that too. But it's not realistic.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

"Computers" is a broad subject. Can you be more specific?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You'll find that we're very patient. But at this point, if the algorithm isn't working it's because something is wrong with your code.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I did. Up above.
I wrote it out.

You posted pseudocode. Please post a complete C program that compiles and runs.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well that's a nice complicated program that violates the premise of the assignments and the teacher would never believe is mine anyway........ : ) : )

Wow. When you described yourself as a "champion puzzle solver", clearly you didn't mean as a programmer. Otherwise you'd be able to see that scudzilla's code is a test framework wrapped around the same algorithm you've been claiming doesn't produce the correct result.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But just for fun-- run it a few times with different combinations and see what happens.

There are only 4! permutations. It's trivial to test this algorithm rigorously by hand.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Try posting in the Hardware & Software category with appropriate tags. That's the "wave of the future" as far as forums and categories go.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

can you please notify me that whether i will get my a/c back or not

Sorry, but that account has been deleted and it's been stated multiple times that the process is irreversible. If there was any question about whether you wanted it back, you shouldn't have deleted it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If I requested 8 bytes of memory, I wouldn't go and try to stick 16 bytes into the block I was just given, so what purpose does it have?

Once again, malloc() is required to align for any type. Just because you requested 8 bytes doesn't negate that requirement. That's not to say malloc() couldn't interpret the requested size and shrinkwrap the alignment accordingly, but the standards committee clearly chose not to go that route.

However, note that C11 (the latest standard) added aligned_alloc(), which supports specifying the alignment you want for a specific object rather than the maximally portable alignment.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Not sure why though, yet...

malloc() is required to give you a block with suitable alignment for any type. That's why it can return a pointer to void which you can then assign to any object pointer type. On your system aligning to the largest scalar type just happens to be the best (hopefully) way to meet that requirement.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I saw this one coming as soon as Dani gave members the ability to delete their account.

They got the power what they wanted, now they have to deal with the responsibility. I find myself lacking any sympathy at all, especially given how hard we make it to delete an account and how many "this is irreversible" notices they have to click through to make it happen.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Because there's no overloaded operator>> that does this for you. It's simple enough to write, though you could just as easily reverse the operation and dump cin into Mystr:

Mystr << cin.rdbuf();

That's probably why the overloaded operator doesn't exist, it's unnecessary.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

1) When you compare a range such do you use && or do you use the or statement to compare them?

You can use either, but typically the result is reversed between then:

// Compare range [lbound, ubound) using &&
if (x >= lbound && x < ubound)
{
    // In range
}
else
{
    // Out of range
}

// Compare range [lbound, ubound) using ||
if (!(x < lbound || x >= ubound))
{
    // In range
}
else
{
    // Out of range
}

2) In c++ you can use the word "and" or the && do these have the same effect?

As a matter of fact, you can and they do. C++ supports alternative keywords for several operators that are problematic internationally. However, note that some compilers won't enable them by default and you need to include the <ciso646> header.

3) When you are useing nested if-then-else such as these do you nest the parenthese such as in the first if statement?

I'm not entirely sure what you're asking, but it sounds like a style question. Do whatever you find to be most readable, but there are a few common bracing styles.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I don't see SqlDbType.Int in any of your parameters. If the error is complaining about converting varchar to int, then it seems one of your columns is defined as an integer and you need to treat the parameter accordingly.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Just make a sum variable and accumulate the results into it:

int sum = 0;

for (int i = 0; i < size; i++)
{
    sum += (test[i] - test[0]);
}

cout << "Sum of differences: " << sum << '\n';
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Are the different high level languages translated into the same MSIL language?

Yes. All of the CLI languages ultimately get translated down into CIL (previously known as MSIL). That C stands for "common", after all. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Great, now print out the contents of buf2 after read() and see if it contains the data you expected. I'm still willing to bet that it doesn't.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

when you use read in your code, your program stops to take input from user

I'm well aware of what read() does.

i set fd and fd2 to zero but still does n't work

fd is set by open(), but fd2 is uninitialized in the code you've provided. Unless your compiler gives it a default value of 0 (some do, but most don't), that means you're telling read() to read from a garbage file descriptor.

What exactly do you mean by "doesn't work"? Print out the contents of buf2 after read() and see if it contains the data you want. I'm willing to bet that it doesn't.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Your code isn't retrieving anything from the command line; argv and argc are unused.

However, I'm not surprised at all that it doesn't work, given that you haven't initialized fd2 to anything. Presumably you wanted to read the "address" from stdin rather than command line parameters, in which case fd2 should be set to 0 (or ideally STDIN_FILENO if you've included <unistd.h>).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You could provide a little utility to your testers that grabs the image runtime version:

using System;
using System.Reflection;
using System.Windows.Forms;

class Program
{
    [STAThread]
    static void Main()
    {
        using (var dlg = new OpenFileDialog())
        {
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Console.WriteLine(
                        "Assembly Runtime Version: {0}",
                        Assembly.LoadFile(dlg.FileName).ImageRuntimeVersion);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.ToString());
                }
            }
        }
    }
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Can Coffee Really wipe out sleepiness. I do it a lot but still i become sleepy.

Coffee doesn't make you less sleepy, it's a stimulant that temporarily suppresses the sleepiness. Like all stimulants, there's a crash when it wears off that has you worse off than before. The best way to avoid sleepiness is to get enough sleep.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This is an obvious answers.

Sometimes the answers are obvious. Not everything has to be complicated. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Apply electric shocks to your genitals.

Kinky.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

it adds automatically an empty line between 1. Item One and 2. Item Two

Yes, that's a quirk or the Markdown formatting that I've been unable to fix without introducing other quirks.

When going to submit I get this error:

Yup, that's because you indented the nested items with a tab or 4+ spaces. Markdown will accept the nesting regardless of source text indentation, so you can just ignore it and leave everything at column 0. However, if you want to have nested lists of the same type, you can use a 1, 2, or 3 space indentation to give a hint to the parser and still get around our code validation. Here's an example with 2 spaces:

* Item One
* Item Two
  * Nested One
  * Nested Two
* Item Three

Which is formatted like this:

  • Item One
  • Item Two

    • Nested One
    • Nested Two
  • Item Three

Also, I thought the absence of an empty line before and after a presumed "code block" as a nested list, would have avoided the check.

No, that ensures that you'll get an error. ;) The editor will not format such text as code, but the validation runs after you try to submit.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What's the favorite OS among the daniweb people? aha

That's a much better question than "which is the best?". My favorite would be Windows 7, but similarity with Windows 7 and obvious improvements make Windows 8 a strong contender. I just have more experience with Windows 7 presently, so it's easier to say that one is my favorite from a knowledgeable position.

Learn your computing history. Linux doesn't do things the way it does to deliberately be different from Windows. Linux was developed by Linus Torvalds because he wanted a Unix system but couldn't afford the exhorbitant licencing fees. He developed Linux to be like Unix, which was around a very long time before Windows or even PCs. Unix was first released in 1969. Windows 3.0 was released in 1990. The Linux kernel was first released in 1991.

It's somewhat amusing that you tell someone to learn their computing history, then immediately proceed to ignore all but the earliest history of Linux to make your point. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

A what?

Begginnerdev commented: Same reaction! +8
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Pass the size in using two more parameters. There's no standard way to determine the size of an array when given nothing but a pointer to the first element.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It really would be best to use word granularity rather than character granularity. Collect all of the words in a list and then you can use a simply greedy word wrapping algorithm to display them in a bounded area. For example:

#include <algorithm>
#include <fstream>
#include <iostream>
#include <regex>
#include <string>
#include <utility>
#include <vector>

using namespace std;

namespace {
    const string::size_type line_width = 40;
}

int main()
{
    ifstream in("test.txt");

    if (in) {
        vector<string> words;
        string line;

        // Build the word list
        //
        while (getline(in, line)) {
            auto x = vector<string>(
                sregex_token_iterator(line.begin(), line.end(), regex("\\s+"), -1), 
                sregex_token_iterator());

            x.erase(remove_if(x.begin(), x.end(), [](const string& s) { return s.empty(); }), x.end());

            for (auto& word : x) {
                words.push_back(move(word));
            }
        }

        // Display each wrapped line
        //
        auto remaining = line_width;

        cout << string(line_width, '#') << '\n';

        for (const auto& word : words) {
            auto width = word.size() + 1;
            bool wrap = width > remaining;

            cout << (wrap ? "\n" : "") << word << ' ';
            remaining = (wrap ? line_width : remaining) - width;
        }

        cout << '\n' << string(line_width, '#') << '\n';
    }
}

How you collect the words is up to you and generally straightforward, so I did something concise. The important part is the word wrapping algorithm.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The main purpose is to show "test" in output

Presumably the purpose is to show 'this is a "test"' as the output. Unfortunately, the code is wrong even if you exclude the syntax error in your return statement. You must escape double quotes in a string:

printf("this is a %s", "\"test\"");
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

they don't explain clearly what the benefit of using them is, why I need them

Say you have two libraries, each in a separate assembly. Neither use namespaces, but both define a class called Widget. How do you know which Widget is which without some way to categorize them? The answer is namespaces.

when I need them

When there's a potential for name conflicts.

and why they're generated automatically

It's best practice to wrap everything in a namespace at the beginning, if only because it saves you the effort when you invariably discover that it needs to be done later down the road.

Say I have a class that I want to use in multiple projects, what namespace do I give it?

Something that's unique and descriptive. For example, I have a scheduling library for polling services with this structure (company name removed to protect the innocent):

CompanyName.Scheduling
    ScheduleEditor
    ScheduleTimer
    ScheduleTimerPulseEventArgs
    ScheduleOverlord

The namespace ensures that when I want a ScheduleEditor, I can get my company's editor by saying CompanyName.Scheduling.ScheduleEditor. We only have one scheduling library, so there's no need to be more granular than that. But ScheduleEditor isn't such a unique name that another third party library we use certainly won't use it.

Everytime I paste a class from one project into another I have to change the namespace and it's getting annoying. How can I avoid this pointless excersize?

Yes, that does get annoying if you …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You probably want the SQLEXPRWT version for your OS, so depending on whether you're using 32-bit or 64-bit, choose one of these:

ENU\x86\SQLEXPRWT_x86_ENU.exe
ENU\x64\SQLEXPRWT_x64_ENU.exe

They include the database engine and basic tools like Management Studio, so it's what I'd consider to be the minimum install for a server. You may also want to install the additional tools package, but it's not necessary to get rolling.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

No, ultimately the sequence you get is still bound by the randomness of the library. But if that process produces a reasonably random seed for the library, it's a net win, though I'm not sure it's worth the effort over something simpler and probably faster like taking a hash of the current system time.

ddanbe commented: I agree, was just wondering. +14
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That does seem to be a browser conformance issue. It doesn't occur in IE9 or 10. I'm a bit torn between saying that a website should attempt to cover the broadest range of browsers possible, and saying that if you're still using IE8 or older you should upgrade as quickly as possible. Or if you don't have that kind of control, slap the shit out of the IT tech managing your machine. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Your examples clearly warrant making an exception.

Be careful what you say, the bracing nazis will come knocking on your door. ;)

Fortunately, very few of my if conditions span multiple lines.

Indeed, I try to avoid it as well, for more reasons than listed above. There are a number of code flow issues that make reading broken lines more difficult, even taking into account that long lines in general have readability problems. That's why I'm somewhat annoyed with modern C++ and C# because both encourage long lines through their standard library.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What looks more pleasing?

I'd add a third option since it's my preference:

if (some condition) {
    true part
}
else {
    false part
}

I prefer the first form. I like a balance between white space and code crunching.

The problem is that your cases are trivial. Consider a long line on the condition that one wants to break into two lines:

if (some long condition &&
    some long conditoon &&
    some long condition) {
    true part
}
else {
    false part
}

This introduces an immediate problem: how do you make a clear separation between the indented condition parts and the if statement's body? You could use a blank line, but I find that less pleasing, so this is a case where I switch to Allman style:

if (some long condition &&
    some long conditoon &&
    some long condition)
{
    true part
}
else {
    false part
}

However, that also introduces an inconsistency with the else clause that uses K&R bracing. So do you just accept it, try to avoid such cases, or use Allman for both clauses?

if (some long condition &&
    some long conditoon &&
    some long condition)
{
    true part
}
else
{
    false part
}

And if you opt for the latter, do you try to resolve the inconsistency with the rest of the code? It's easy to make a case for the simple examples, but when the code becomes more realistic there can be …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The MouseMove event needs to take the current state of drag into account:

Private Sub PictureBox1_MouseMove() Handles PictureBox1.MouseMove
    If drag Then
        Me.Top = Windows.Forms.Cursor.Position.Y - mousey
        Me.Left = Windows.Forms.Cursor.Position.X - mousex
    End If
End Sub
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I had no idea you lived so close by. I live in Marietta as well!

Small world. :)

I gather this group is open to guys like me?

It's open to anyone, as far as I know.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I live in the north metro area of Atlanta.

The .NET users group meets at the Microsoft offices in Alpharetta. If nothing else it's a good way to network with other developers and ask about targeted courses. I wish I could say I'd see you there, but I'm too lazy to drive even from Marietta to Alpharetta for the meetings, so I've never gone except on business. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If you're still using the above code, then inname hasn't been initialized. However, you won't have any problems with it unless you enter the case of a file not being able to be opened (ie. infile is NULL).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That program was an example, not a solution to your exact problem. You're supposed to learn from it and use it as a template for constructing a program that does solve your exact problem. I won't do your work for you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The simplest approach would be fgets() and strtok(). Here's a quickie example:

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

int main(void)
{
    FILE *in = fopen("test.txt", "r");

    if (in) {
        char line[BUFSIZ];
        char *tok;
        int i = 0;

        while (fgets(line, sizeof line, in)) {
            line[strcspn(line, "\n")] = '\0'; /* Trim the newline if present */
            tok = strtok(line, ",");

            printf("Line #%d\n", ++i);

            while (tok) {
                printf("\t'%s'\n", tok);
                tok = strtok(NULL, ",");
            }
        }
    }

    return 0;
}