deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But it doesnt make sense thread to make a question thread a article either.......

I think you're making a mountain out of a molehill. So far the only one who has really been bothered by the terminology is you. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There problem is exactly as stated. sequence is a pointer to char (a dynamic array), so sequence[i] produces a single character, not a pointer to a character. I can't say how to fix it because I'm not sure what you're trying to accomplish with that line, but on the assumption that you're trying to get the length of the substring starting at i, you can do this:

char* arr = &sequence[i];

Taking the address of the character produced by sequence[i] will give you a slice of the string. Alternatively you can use this syntax if it's more intuitive:

char* arr = sequence + i;
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I just noticed this as well. Dani has been tweaking the editor and posting process, so something may have gotten through accidentally. I'll take a look.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

A constructor may only called during a declaration (under normal circumstances), so your code should look like this if you want to reset the dent_space1 string object:

dent_space1 = std::string(max_space, ' ');

Or since the object already exists:

dent_space1.assign(max_space, ' ');
Vasthor commented: thnx for the second method! +2
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

All admins, moderators, team colleages are employees or some of them just contribute their time to site. And if they are employees how do you work together? at one place?

Any compensation is between the individual and Dani, but to the best of my knowledge the team is mostly composed of volunteers. And only Dani and Kerry work from the Daniweb office. The rest of us are in our respective homes and home lands. We communicate through the forum, private messages, email, and in some cases (such as Dani and I discussing more extensive coding tasks) we speak on the telephone. Daniweb also has events every now and then in New York, for those who are able to travel there and participate, but that's open to anyone and not just team members.

Also Can I ask if you know what happened to Narue?

Narue has decided to retire her account on Daniweb. Sanjay and I will be picking up the slack as the two new admins.

Sahil89 commented: Perfect answer :) +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i need to display the numbers 1 to 9 randomly but they cannot be repeated!

Then technically it's not random. ;) There are two ways to get a non-repeating set of random numbers:

  • Store the generated numbers and try again if you generate one that's already been generated.
    #include <algorithm>
    #include <iostream>
    #include <iterator>
    #include <vector>
    #include <cstdlib>
    #include <ctime>

    using namespace std;

    int main()
    {
        srand((unsigned)time(0));

        vector<int> rnum;

        while (rnum.size() < 9)
        {
            int r = 1 + rand() % 9;

            if (find(rnum.begin(), rnum.end(), r) == rnum.end())
            {
                rnum.push_back(r);
            }
        }

        copy(rnum.begin(), rnum.end(), ostream_iterator<int>(cout, " "));
        cout << endl;
    }
  • Fill an array (or other data structure) with the full range of numbers you want, then randomly shuffle it.
    #include <algorithm>
    #include <iostream>
    #include <iterator>
    #include <vector>
    #include <cstdlib>
    #include <ctime>

    using namespace std;

    int main()
    {
        srand((unsigned)time(0));

        vector<int> rnum(9);

        for (vector<int>::size_type i = 0; i < rnum.size(); i++)
        {
            rnum[i] = i + 1;
        }

        random_shuffle(rnum.begin(), rnum.end());

        copy(rnum.begin(), rnum.end(), ostream_iterator<int>(cout, " "));
        cout << endl;
    }
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I agree, that rotating array is better, but I decided to do it with queue.

A queue is an abstract data type, the rotating array is one option for implementing a queue. Just FYI.

Can you help me with that to?

If you have any specific problems with your code, feel free to post them on this forum and someone will help you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

How do we add an attachment to a post?

In the post editor there's a button called Files. Click that guy to bring up the attachment view, and from there it's your typical file upload process.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I think the main thing I'm not entirely sure of is how to "cut" the numeric format down and get the last two digits for the "secret message".

Use division and remainder math:

19546 / 100 = 195
19546 % 100 = 46

It's easier to keep the numbers stored as integers so that you can use them as indexes in the key lookup without doing a string -> integer conversion. Of course, if the message is long enough for the sequence number to overflow and integer you'll need to approach the problem differently, but I don't think that'll happen provided you use long int as the data type (note that int is only guaranteed to be at least 16 bits).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It was your control panel in vBulletin. The new design is intentionally "plain" because it's only a first version of the system and a simpler design improves both performance and usability. The control panel from vBulletin in particular was excessively complicated and it confused people.

Now that we're relatively stable from the initial bugs, feel free to make feature requests. But please provide a specific description of what you want. Using your description of the lost features, "statistics about traffic income to daniweb for code snippets and stuff like that", isn't quite detailed enough to work out a new feature design.

Philippe.Lahaie commented: +1 for "control panel" ! :D +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is there a way to stop urls parsing automatically?

I saw this one coming. ;) My answer from before isn't valid anymore because both the live editor and back-end parser are converting HTML into straight text rather than parsing it. However, the automatic linkification of a URL only applies if you include the protocol at the beginning, so http://www.google.com will be linkified while www.google.com will not. This is a convenient quirk of the heuristic being used to match a URL.

If that's not enough, I can hack in an exclusion character such that something like ^http://www.google.com would disable linkification and the exclusion character (a leading caret in this example) wouldn't show up in your post. But I suspect that's not necessary as just trimming off the protocol should be sufficient. :)

And Quotes just seem to be a pain in general. Isn't there any way to quote without copy/paste -- like before the change?

Quotes aren't line based, they're paragraph based. Maybe they seem to be a pain because the quote button prefers to place a quote starter on each line. However, you can just plop down a quote starter at the beginning of each paragraph (ie. block of text without a blank line at the end) and it'll be properly quoted.

diafol commented: great ^ it is then :) +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well one more doubt, are users allowed to take back the reps too... That right was reserved for Ms dani in last version!!

Dani was kind enough to give the rest of us that ability. Any verified member can undo reputation.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

BBCode no longer works for new posts, it's all Markdown based now. As far as making a code block, it's a matter of indentation (at least 4 spaces). Presently the code button only pastes an example into the editor if there's no text selected. To paste actual code, you would just paste it in, then select the entire block and hit tab or click the code button.

Another option is wrapping your code in ~~~, which will force a code block without the need for indentation.

I recognize that selecting the code to turn it into a code block is awkward, we're working on making the editor more convenient. ;)

I tried using the Code button but that didn't seem to work either (i.e. past code into editor, highlight, then hit the Code button).

I just tested and it appears to work properly. Can you reproduce the problem consistently with all options described above?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It was just poorly designed I guess.

Thank god I wasn't the one who wrote the private messaging subsystem...oh wait, it was me. ;)

By the way, I'd like to upload an avatar but don't remember the limitations i.e. max. kilobytes/pixels?

Current limitations are GIF, JPG, or PNG at up to 640x480 or 500kb to upload. From there we'll resize down to 80x80. It looks like that resize isn't working properly, because I get a broken image in all cases. Chalk up another bug for the list. ;)

mitrmkar commented: Thanks +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is there a way to see the threads by last post first in the new system ?

Not presently, but that wouldn't be a difficult feature to add. Can I get a rain check until we clear up some of the post-deployment hiccups? :)

Gribouillis commented: ok +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

As a senior systems engineer for a tier-one world-wide engineering company, you must be familiar with the mutually exclusive goals of getting things perfect and meeting deadlines. There was immense pressure to get this system rolling before a hard and somewhat unreasonable deadline, and we'll be working equally hard to "sort out this cruft" as quickly as possible.

In the meantime, I hope you enjoy whatever alternative you choose for spending time that would otherwise have been spent on Daniweb.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

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)

What's wrong with simply abandoning your account? If we don't care about a dead account on our database, why should you care? ;) Just remove any personal information and call it a day, no loss, no foul.

2) Why it should be done?

Because you should honor the wish of your users if it is feasible (see next point)

We try to honor requests when they make sense and are possible. In many cases it doesn't make sense because it would create a precedent that complicates the interpretation of our rules. In the case of deleting an account, we simply cannot honor the request and still adhere to anti-spam laws.

3) Is it feasible to clean/remove an account?

Yes, don't tell me not, I'm an IT specialist and I know you can, it's a question to write the right piece of code in any language of this world.

Let's consider it then: We're legally obligated to retain records of all registrations as proof of opt-in because we send bulk emails. So there are two options to handle the deletion of an account:

  1. Store separate registration information such that an account could be physically deleted.
  2. Fake it by hiding "deleted" accounts.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

hello !
well today i got two down votes , i dont think that there is any thing wrong with my post , as we know who add reputation to us , can we know the person who is down voting us , and is there any way to balance them , well this thing make me feel very bad , i always tried to help others and to share my knowledge and to learn something new from you experienced people.but this thing is very bad , :( , i spend lots of time when someone post a question to answer him , am i doing all this to get down votes :( ,

Regards

I'm sorry you feel bad about getting downvoted, and I'm also sorry for the harsh tone of this reply, but I can't think of a softer way to say what I want to say at the moment.

No matter what you say, someone will always disagree with you. If you think you're being harassed, we can look into who might be doing it. As far as wanting to know who an anonymous voter is, the only other reason I can think of is you want to reciprocate, and nothing good can come from that.

as we can not give reputation with out giving any reason , they can make it possible with down vote also .

We may do that in the future, but for now the intended design of the voting …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Some of those overlap with the standard C# library, what's the benefit of using your versions?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Visual Studio doesn't support variadic templates yet.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

More like it's filtering out the better candidates because they won't consider an employer that cares more about trivia than real skills.

zeroliken commented: Agree :) +9
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The overloaded<< operator only allows non-const references, which excludes temporaries like the ones returned by transpose() or calculated with the overloaded operator*. You should change it to expect a reference to const instead as you don't make any changes to the object's state:

ostream &operator<< (ostream &out, Matrix const &myMatrix)
{
	for(int i=0; i < myMatrix.num_rows(); i++){
		for (int j=0; j< myMatrix.num_cols(); j++){
			out.width(3);
			out << myMatrix.get_element(i,j) << "  ";
		}
		out << endl;
	}
	out << endl;
	return (out);
}

That also requires the called methods of num_rows(), num_cols(), and get_elements() to be declared as const methods, but that's how they should be defined anyway to maintain const correctness:

int Matrix::num_rows() const
{
	return numRows;
}

int Matrix::num_cols() const
{
	return numColumns;
}

ElementType Matrix::get_element(int row, int col) const
{
	return myArray[row][col];
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I already know syntacs of OOP in PHP, but I find it kind of hard to start working with it, I can't find some nice and SIMPLE examples of object oriented PHP.

In my experience you won't find good *and* simple examples. OOP is best suited to larger projects, and larger projects have a tendency to be anything but simple. ;)

My question is, should I start with that framework now, with limited knowledge of OOP or I should master OOP first?

I'd say start working with the framework and learn OOP as you go. You're not going to master OOP without using it in real applications anyway, and missteps are to be expected, so go at it and don't be afraid to mess up a design or two. Throwing away failed attempts comes with the territory.

I'm not sure I will understand it completely if I'm not comfortable with Object Oriented Programming first.

Perhaps not, but in figuring it out, you'll become more comfortable. Here's a shocking revelation: professional programmers learn things on the way and rarely are comfortable with all aspects of any new project unless they've holed themselves up in a comfortable niche.

zack654 commented: Thanks a lot mate ;) +1
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Wow, there are some unsympathetic people here. :icon_rolleyes: If it's legitimate harassment then that's an issue, but to the best of my knowledge there's no way to find out who is doing the voting without direct database queries, if that information is presently stored at all.

You'd need to contact Dani for such a task as she's the only one with database access in the current system.

happygeek commented: Agreed +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Why do you need a 2D array if you already have a class holding the data?

personClass[] people = new personClass[N];

for (int i = 0; i < N; i++)
{
    people[i] = new personClass();

    people[i].Name = "John Doe";
    people[i].Address = "123 Nowhere Lane";
    people[i].Phone = "(555) 555-5555";
    people[i].PostCode = "12345";
    people[i].Height = "182cm";
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

so, info is a Information struct

Those two lines are only meaningful if info is a pointer to an Information object.

is there any different between the two shown above?

Nope, the arrow operator is for convenience when dereferencing a pointer member.

and what is "->" and "." called?

They're the the arrow and dot operators. :)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Endianness only matters when you make an assumption about how bytes are organized. Bitwise operators will work with the value and have consistent behavior regardless of the endianness of the system, and that's one way to ensure portable code when sending or receiving binary data:

#include <algorithm>
#include <iostream>
#include <iterator>
#include <limits>
#include <type_traits>
#include <vector>

using namespace std;

template <typename T>
vector<unsigned char> GetBytesNonPortable(T value, typename enable_if<is_integral<T>::value>::type * = nullptr)
{
    // Extract bytes as stored in memory (different endianness will give different results)
    unsigned char* pun = (unsigned char*)&value;

    return vector<unsigned char>(pun, pun + sizeof(T));

}

template <typename T>
vector<unsigned char> GetBytesPortable(T value, typename enable_if<is_integral<T>::value>::type * = nullptr)
{
    unsigned const bits = numeric_limits<unsigned char>::digits;
    unsigned const max = numeric_limits<unsigned char>::max();

    vector<unsigned char> result;

    // Extract bytes regardless of endianness
    for (size_t i = 0; i < sizeof(T); i++)
    {
        result.push_back((value >> (bits * i)) & max);
    }

    return result;
}

int main()
{
    int value = 12345678;
    vector<unsigned char> v1 = GetBytesNonPortable(value);
    vector<unsigned char> v2 = GetBytesPortable(value);

    copy(v1.begin(), v1.end(), ostream_iterator<int>(cout, " ")), cout << endl;
    copy(v2.begin(), v2.end(), ostream_iterator<int>(cout, " ")), cout << endl;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It's the preprocessor's pastie operator. It takes two tokens and concatenates them into a single token. For example:

#include <stdio.h>

#define PASTIE(prefix, var) prefix ## var

int main(void)
{
    char const* strFoo = "foo!";
    
    puts(PASTIE(str, Foo));
    
    return 0;
}

Neither str nor Foo are meaningful by themselves, but when combined they match the variable name strFoo, so this code both compiles and prints "foo!" to stdout.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You're not doing anything wrong. Windows Forms is notorious for having a noticeably slow redraw out of the box. There are a number of ways to improve matters, but the list is kind of long, so I'll just suggest searching google.

One thing to keep in mind is that C# has to go through the .NET framework while VB6 would hit the Win32 API directly. There's a whole extra layer or two difference, though that's not an excuse for the unresponsiveness of WinForms. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Uninitialized pointers are not pointers to infinite memory. You have to allocate memory before trying to write to it:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    struct Person
    {
        char *firstName;
        char *lastName;
    };

    struct Person newPerson;

    newPerson.firstName = malloc(50);
    newPerson.lastName = malloc(50);

    printf("Enter your first name and last name: \n");
    scanf("%49s %49s", newPerson.firstName, newPerson.lastName);
    printf("Hello %s %s! \n", newPerson.firstName, newPerson.lastName);
    
    free(newPerson.firstName);
    free(newPerson.lastName);

    return 0;
}

It's also best to check and see if malloc() returns a null pointer, but I won't complicate the example with that yet.

DeanMSands3 commented: I was about to post something on malloc, but decided the poster wouldn't get it. Rock on, deceptikon. +4
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You got neg rep from me because you are telling a student uncomfortable with
1) programming -- he's NEW!!
2) English -- he's from Malaysia

I'm sorry, I didn't realize I was supposed to read his mind and determine that what he asked for wasn't what he really wanted. :icon_rolleyes:

He just want's to know how to ask a question again when an improper answer was entered, not to take over the screen and bounce all around it!

Read the first post again. It's not clear that's what he wanted to know, and what he *asked* for was how to move the input cursor to the previous line. Maybe you should take such things into account before whipping out your bad attitude.

inb4 more negative rep from WaltP.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The code continually allocates new memory to ptr, which leaks away the previous memory and loses any previously assigned numbers. Rather than outline all of the possible cases and explain why they're necessary, I'll just give you a function to study:

bool ResizeArray(int*& a, unsigned old_size = 0, unsigned new_size = 0)
{
    bool rc = false;
    
    if (new_size != 0 && old_size != new_size)
    {
        if (!a)
        {
            // Allocate a new array of non-zero size
            //
            try {
                a = new int[new_size];
                rc = true;
            }
            catch (...)
            {
                // No cleanup, just converting an exception into a return code
            }
        }
        else
        {
            // The new size is different on an existing array; try to resize
            //
            unsigned n = new_size > old_size ? old_size : new_size;
            int* temp = nullptr;
            
            try
            {
                temp = new int[new_size]; // Might throw
                
                for (int i = 0; i < n; i++)
                {
                    temp[i] = a[i]; // Might throw
                }
                
                delete[] a;
                a = temp;
                rc = true;
            }
            catch (...)
            {
                if (temp)
                {
                    delete[] temp;
                }
            }
        }
    }
    
    return rc;
}

Don't copy it mindlessly, try to understand what's being done, in what order, and why. There are three steps:

  1. Allocate a temporary array.
  2. Copy existing elements into the temporary array.
  3. Replace the original array with the temporary array.

But the logic varies depending on things like if the original array hasn't yet been allocated any memory and is a null pointer, and the relationship between the old size and the new size.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

>> kingsonprisonic.

???

The guy who posted using goto, once again assuming you're replying to me. Could you be more clear with whom you're replying to and why, please?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You need to run the query before trying to parse the results. :D

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So, it does not, IMO, belong in this C++ discussion thread.

Your opinion doesn't define what's topical for this forum. If you don't know C++/CLI or don't agree with it, you're not required to participate in any threads about it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The problem is not with fgets() reading a newline character, it's with scanf() leaving a newline character in the stream for fgets() to read. To fix the problem, change how you're using scanf(), or use a different method of input.

There are two common recommendations. First, you can avoid scanf() altogether and always use fgets() for stream input. Then the string retrieved by fgets() can be parsed in memory without any worry of mucking up the stream.

#include <stdio.h>

int main(void)
{
    char line[BUFSIZ];
    int value;
    
    if (fgets(line, sizeof line, stdin) &&
        sscanf(line, "%d", &value) == 1)
    {
        printf("The integer you typed is %d\n", value);
    }
    
    return 0;
}

Second, you can try to clean up the stream after calling scanf() like zeroliken's code:

#include <stdio.h>

int main(void)
{
    int value;
    int rc = scanf("%d", &value);
    
    if (rc != EOF)
    {
        int ch;
        
        // Clean up the stream (assumes everything left is garbage
        while ((ch = getchar()) != '\n' && ch != EOF)
        {
            // All work done in the condition
        }
    }
    
    if (rc == 1)
    {
        // Display the value if it was successfully read
        printf("The integer you typed is %d\n", value);
    }
    
    return 0;
}
zeroliken commented: I wasn't familiar with the first one so thanks for posting +8
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

strcmp returns the difference of the two strings. If the first string is "less" than the second string it returns a value less than 0. If the first string is "greater" than the second string it returns a value greater than 0. And if the two strings are identical, it returns 0.

Here's an example implementation:

int my_strcmp(char const* a, char const* b)
{
    // Find the first two characters that don't match
    while (*a == *b && *a)
    {
        ++a;
        ++b;
    }

    // Compare the mismatched characters and return the absolute difference
    if (*a < *b)
    {
        return -1;
    }
    else if (*a > *b)
    {
        return +1;
    }
    else
    {
        return 0;
    }
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

p is a pointer to char, not int. So when you increment by 1, it increments by 1 byte instead of the number of bytes in an int. I think you should throw that book away if that program is a sample of its quality.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

so it means any kind of list i use, its iterator will return the pointer of the nodes of the list..

Not really. It means that iterators in C++, at least the ones following convention, are an abstraction of pointers. They overload operators in such a way that they have a subset of pointer operations depending on the type of iterator. All iterators have a dereference operator to access the "pointed to" object.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

An easy way to use variadic template functions is with direct recursion:

#include <iostream>

using namespace std;

void foo()
{
    // Base case for variadic recursion
}

template<typename T, typename... Args>
void foo(T first, const Args... remaining)
{
    // Use the first argument
    cout << first << endl;
    
    // Recursively pass on the remaining arguments
    foo(remaining...);
}

int main()
{
    cout.setf(ios::boolalpha); // To make bool args print right
    
    foo(1, "test", 3.14159, 'Q', true, 6);
}
triumphost commented: Doesn't work but thanks anyway Rep+1 +6
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Show me your attempt and I'll show you mine.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I think the "forum index link" isn't such a but idea but after reading deceptikon's post it seems it would be a lot of work for Dani to make it possible
though Dani is currently working on Daniweb's new version so I think it's better if we hear it from her of what she thinks about this

Actually, that change will border on the trivial when the new system is released, at least as far as the code itself goes. But I'm told there was a lot of research into the design of the site, and I'm not privy to the details.

I like to be able to see every category and which category has unread posts.

I have a few thoughts:

  1. We could show the read status of a category from the category menus at the top of each page.
  2. We could change the New Posts button on the purple bar into a menu filtered by forum.
  3. We could leave the New Posts button a straight up button, but add filtering by forum to the results.

Viewing the read status from places other than a forum view or the forum index is a good idea as long as it doesn't increase loading time excessively.

I can also mark the whole forum read from that page.

You can mark a whole forum read from the forum view, but the link is at the bottom of the page. Off the top of my head I …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

eq->pt_tree[row][col] = value; is equivalent to *(eq->pt_tree[row] + col) = value; .

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Depending on the topic of your threads, I'd say one of the Microsoft Windows sub-forums or Web Development sub-forums would be the best fit as it stands now.

Adding a forum isn't technically a huge deal, but there needs to be sufficient demand first. Otherwise we'd end up with the eyesore of a low activity forum on a site that already has an overwhelmingly large number of forums.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Do you have to be like a master programmer in a certain language to land a job in this field?

Of course not. The idea that professional developers are always masters of the craft is a romanticized fantasy that hobbyists dream up. The reality is that only a small fraction of professional developers are more than average programmers.

Mrewan79 commented: This is true. There's a lot of bluff +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

which is the best programming language between java and .net.

.NET isn't a language, it's a framework. You probably mean Java and C# as they're very similar in terms of syntax, but it's still impossible to compare languages without a very specific context and well defined points of comparison. Just asking which is better will get you nothing but subjective answers.

JAVA would be slower than .NET since there is a middle man (JRE). In other hand, JAVA comes for FREE..

Both points are incorrect. Java supports JIT compilation just like .NET languages, and the slowness argument stopped being valid around the turn of the millennium when Java started to really mature. Also note that .NET's CLR roughly corresponds to the JRE in terms of being a "middle man".

Like Java, .NET as a development platform including a compiler can be downloaded for free, and you can even get Visual Studio, one of the better IDEs on the market, in one of the free Express versions.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I assume you're using a Linux system and not MinGW because MinGW's gcc supports getch(). You can reproduce the effect of getch() on Linux like this.

Arch Stanton commented: On Linux, using gcc 4.4.5; getch() works for me! +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Just one final question for my understanding.
Can anyone explain to me what the arguments in the for loop?

for (char *p = strtok(str, fmt); count < MAX && p; p = strtok(0, fmt))
    {
        strcpy(strWords[count++], p);
    }

strtok() has two steps: set the source string/return the first token, and return subsequent tokens on the source string. Because strtok() stores a pointer to the source string internally, any subsequent calls after the first must have a source string of NULL. The pattern looks like this:

char* tok;

tok = strtok(source, delim);

while (tok != NULL)
{
    // Use tok

    tok = strtok(NULL, delim);
}

The first thing I did was merge that into a for loop to make the unusual behavior of strtok() more clear:

for (tok = strtok(source, delim); tok != NULL; tok = strtok(NULL, delim))
{
    // Use tok
}

Then I replaced NULL with 0 because that's the convention in C++. In the new standard, nullptr is recommended. I also removed the redundant test against NULL in the loop condition because it happens implicitly just by using tok. Finally, I defined tok as local to the for loop by declaring it in the initialization clause:

for (char* tok = strtok(source, delim); tok; tok = strtok(0, delim))
{
    // Use tok
}

That's for the use of strtok(). The extra test of count < MAX just makes sure that the loop doesn't try to call strcpy() on an index that doesn't exist if there …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It's probably safer to say that there's hidden initialization and termination code in your program's executable. While it's correct to say that main() is the starting point for a program, it's not necessarily the first starting point. When your executable is loaded into memory, the starting address is probably at mainCRTStartup() instead of main().

myk45 commented: Thanks! +6