deceptikon 1,790 Code Sniper Team Colleague Featured Poster

"better" requires creativity, originality and so on...

Only in situations where creativity, originality, and so on are required. "Better" is subjective, and it's prefectly reasonable to say that a code monkey can get "better" without being more creative or original.

when you are experienced you tend to avoid trials and go strait to results.

When you're experienced, your trials just become that much more complex. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There are a number of issues including:

  • The list in main is never updated.
  • Your only reference to the list in insert is lost during the loop.
  • A null list isn't properly accounted for in insert.

Consider the following changes:

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

struct list
{
    int data;
    struct list* next;
};

struct list* insert(struct list* node, int data)
{
    struct list* newnode = malloc(sizeof(struct list));

    if (newnode)
    {
        newnode->data = data;
        newnode->next = NULL;
    }

    if (!node)
    {
        node = newnode;
    }
    else
    {
        struct list* temp = node;

        while (temp->next)
        {
            temp = temp->next;
        }

        temp->next = newnode;
    }

    return node;
}

void printlist(struct list *node)
{
    if (!node)
    {
        printf("empty list\n");
    }

    while (node)
    {
        printf("The list contains %d \n", node->data);
        node = node->next;
    }
}

int main(void)
{
    struct list *temp = NULL;
    int i, n, m;

    printf("ENTER THE NUMBER OF ELEMENTS\n");
    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%d", &m);
        temp = insert(temp, m);
    }

    printlist(temp);

    return 0;
}
Qwert_1 commented: Could you please explain me how is the insert function working here? :) +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

An exclusion scanset (the %[^ specifier) won't extract any of the excluded characters, so the stream still contains a comma after HuffOriginal is extracted. The simple answer is this:

sscanf(buffer, "%[^,],%[^\n]", HuffOriginal[i], HuffSymbol[i]);
billkas commented: Thanks! +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

POLINK: error: Unresolved external symbol 'WinMain'.

You're trying to compile the project as a Windows application rather than a console application. Windows applications use a different entry point called WinMain. This is an easy one to fix, just change the appropriate setting for your project to build a console application.

somjit{} commented: thanks :) +3
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You don't need the strcat() in this case, just sprintf():

sprintf(f, "N%d", k);

Cue everyone telling you to use std::string instead of C-style strings.

manel1989 commented: 5 +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You want some variant of getch(). However, note that raw input is not portable, so you'll be using something specific either to your compiler or operating system.

This may help, since I don't particularly feel like writing a raw input example for the umpteenth time. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But how does a junior poster in training become one? (I'm just curious)

It's a judgment call amongst the current moderation team. Somebody nominates a member as a moderator to get our attention, then we decide if a new mod is needed and vote on whether to offer an invitation if that's the case.

Anyone can be nominated. However, certain metrics do help in that we can see how the community already views the nominee and how the nominee participates in the community. Metrics that help include post count (ie. activity), solved threads, reputation, and upvote:downvote ratio.

We also (most importantly) look at the nominee's suitability as a moderator, such as maturity, ability to look at situations objectively, and ability to disassociate from emotion when making a decision.

~s.o.s~ commented: Can't put it any better +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

My condolences to the new mod. ;)

JorgeM commented: haha, thanks! +0
bradly.spicer commented: Made me giggle xD - Xtrapsp +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Each node is just an anonymous variable that the pointer points to. It seems like your confusion is more about self-referential structures than anything. So let's take a look at a simple linked list:

#include <iostream>

struct node {
    int data;
    node *next;

    node(int data, node *next = nullptr): data(data), next(next) {}
};

int main()
{
    node *head = nullptr;

    for (int i = 0; i < 5; i++) {
        head = new node(i, head);
    }

    for (node *x = head; x != nullptr; x = x->next)  {
        std::cout << x->data << '\n';
    }
}

Your question is about why all of those next pointers don't overwrite each other, but conceptually the list looks like this if you unroll the loop and name each anonymous variable:

#include <iostream>

struct node {
    int data;
    node *next;

    node(int data, node *next = nullptr): data(data), next(next) {}
};

int main()
{
    node *head = nullptr;
    node a{0}, b{1}, c{2}, d{3}, e{4};

    head = &e;
    e.next = &d;
    d.next = &c;
    c.next = &b;
    b.next = &a;

    for (node *x = head; x != nullptr; x = x->next)  {
        std::cout << x->data << '\n';
    }
}

Each pointer points to a unique entity in both cases, the first case simply hides that from you by using anonymous objects versus named variables.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You could try Daniweb chat for such things. ;) However, I don't think this kind of question is unsuited to a thread, especially since you might get a large number of differing opinions and a very interesting debate out of it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If I ever feel strongly enough about a downvote to give a reason, I make sure to provide a comment and it becomes negative rep.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I want to allow only numbers (int & float data type) input. How will I do that?

The usual and recommended approach is to simply allow the user to type anything and then throw errors if it doesn't match what you're expecting. For example with numbers only:

#include <ios>
#include <iostream>
#include <limits>

using namespace std;

int main()
{
    double num;

    while (true) {
        cout << "Enter a number: ";

        if (cin >> num) {
            break;
        }
        else {
            cout << "Invalid input. Please try again\n";

            cin.clear();
            cin.ignore(numeric_limits<streamsize>::max(), '\n');
        }
    }

    cout << "The square of " << num << " is " << num * num << '\n';
}

This takes advantage of the fact that cin's operator>> will perform formatting and error checking on the input string based on the type of the target variable. In this case, operator>> will try to ensure that the input string is a valid floating-point value.

In cases where the default validation doesn't fit your needs, you would read the input as a free-form string and then validate it yourself. However, that's not typically recommended for basic cases as it can get complex quite quickly.

Finally, some people want to restrict input at the keyboard level. For example, completely disabling the non-digit keys when they're typed. This isn't supported by C++ natively, so you would need to write a non-portable input function that takes over the job of the command shell:

#include <cctype>
#include <iostream>
#include <string> …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I have a code that when mouse hovers a button then it fires click event.

I would strongly recommend against this approach because it's unconventional and surprising. If an application I used did this, I would stop using it post-haste and look for an alternative.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You can pass a ref parameter in C++/CLI using the '%' operator, it corresponds to standard C++'s reference operator(&):

int MediaMogul::readlist(String^% name)
{
    name = "changed value";
    return 0;
}
n1csaf3 commented: Thankyou, I also worked out from that how to pass to the C++ DLL using item.readlist(ref name); in C# +0
ddanbe commented: Deep knowledge! +14
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

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 #3", c, a, b);

It's not even worth mentioning, because it's obvious to anyone who bothered to read a book or reference on C#. Of course, if your taget audience is the folks who learn by random guessing, then it might be helpful.

RIGHT AND PERFECT:: Console.WriteLine("{0} * {1} = {2}",c,a,b);

Actually, I'd wager that your right and perfect answer is actually incorrect. If it's not incorrect, it's misleading because the usual convention is for c to contain the result of a binary operation:

Console.WriteLine("{0} * {1} = {2}", a, b, c);
ddanbe commented: Well said. +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

it is my opinion, may be i am wrong in this

As far as Daniweb's rules go, RJ wasn't even close to breaking the Keep It Pleasant rule. If the moderators or long time members don't call someone on their behavior, chances are that it's acceptable within the community.

atleast we must filter these words when anyone try to write these words.

We do filter such things (so if it's not filtered, it's OK), and also have rules in place to deal with excessively bad behavior. If you feel someone is being excessively rude, report the post and let a moderator deal with it. If it's not worth reporting, the problem is on your end. I think you're being too sensitive, which could very well be the overall problem that prompted this thread in the first place. Grow some thicker skin, dude.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Although possibly questionable ethically and technically, there is some mileage in the reasoning behind being the only one who understands your coding.

True, it's usually perceived as job security. However, I find that attitude so repulsive I'd be willing to fire an employee for it and give the new employee bonuses for the pain and suffering of figuring out or rewriting the obtuse code. A programmer that writes bad code as job security isn't the type I want to employ.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If one can write an algorithm that is significantly faster than a brute-force one, that is better.

Is it? What if the brute force algorithm was fast enough already? What if the faster algorithm is so godawful complicated that the original author barely understood it and left the company? One of the first things I try to teach college grads is cost benefit analysis for code. It may be cool, or theoretically superior, but if the cost exceeds the benefit, it's an inferior solution.

But all my peers and companies that recruit interns look for people who can write algorithms that are fast.

Obviously you shouldn't intentionally write slow code, but fast has a price, and if an employer doesn't understand that, they're not worth working for.

I just fail to see the wonderful patterns that arise out of the better(faster) algorithms.

Studying algorithm and data structure design would be a good start. Without a strong foundation in the theory, I'm not sure you'd suddenly start seeing those wonderful patterns just because you're under a time or resource crunch.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Define "better". Do you want to win contests or be a good programmer in general? Do you want to write professional quality code or code that just solves the problem as quickly as possible, and maintainability be damned?

That's the difference between competition and software development. Most of the time, code that should be in contests would miserably fail a code review. Likewise, good production code will general lose a contest consistently.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Throw it out before it kills you.

BBCode was far worse, and throwing out both pretty much exhausts our options if we want to be consistent with what people know and understand.

What is more important?
1 You and your staff like it.
2 Members like it.

Of the two you stated, we chose #3: members are capable of using the formatting system without screwing it up 8 times out of 10. With BBCode we often spent more time fixing people's mistakes than fighting spam, and with the huge bullseye to spammers that vBulletin is, that's saying something.

Clicking on Log Out I ended up with:

What page were you on when you clicked the Log Out link?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I don't think that people are that blind or illiterate to not see or understand that a solved ie 5 year old thread, has a five years old solution!

Even with the big notification in the quick reply, we still see people posting to threads that are several years old as if they were started just yesterday. It's a short leap to imagine people voting with the same tunnel vision.

I'm not arguing for or against a time limit, just pointing out that this situation is far from improbable.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's because Daniweb is infinite.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

because u asked some bad things to him otheriwse all 4 rounds response ws awesome for you.

Your summary of the situation puts the interviewer in a negative light. I'd suspect that while your technical skills were good, they didn't feel you were a good fit for the environment due to your questions. There's not much you can do about that; if you got the job then there may be a higher chance you'd be unhappy with it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

How can I do it with sprintf()? Before I posted here, I scoured the internet all over, and all the explanations for sprintf were to complicated. I couldn't understand.

If AD's example above was too complicated, I'm not sure what to tell you, because that's as simple as it gets. For your specific needs:

double n = 1.23456;
char s[10];

sprintf(s, "%.2f", n);

In C++ there are many more options, but I suspect those will confuse you as well. The usual solution involves stringstreams:

double n = 1.23456;
ostringstream oss;

oss.precision(2);
oss << fixed << n;

string s = oss.str();
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I tried this, but i get debug assertion failed. From what i've read, it's because my object are destructed for a multiple number of times.

If you're calling the destructor multiple times, something is very wrong with how you're using the class. Perhaps you're trying to delete the object pointer twice?

std::string is STL? because we are not allowed to use it.

Technically std::string isn't a part of the STL, but it is part of the extensive standard library of which the STL is a subset. If you aren't allowed to use "the STL", std::string is very likely to be implied in that restriction.

@deceptikon, why do i have to implement a copy constructor and to overload the assignement operator when creating a destructor?

Because if you use the default copy constructor and assignment operator, you'll have two objects that refer to the same block of memory. This is a very risky situation that would end up in trying to delete the pointer multiple times (on the destructor call of each object).

This is the rule of 3 (and more recently the rule of 5) intended to handle the management of resources owned by a class as safely and completely as possible.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

why is mName char* instead of std::string?

From previous threads, I can safely conclude that the OP isn't allowed to use such convenient classes yet.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yes, you can certainly discuss those things. Though the topic is rather broad, and in the case of "is it okay to do/say XYZ" the general advice stands: if you have to ask, it's probably not okay.

p.s. The only way to feel comfortable in an interview is to not want the job and not care what the interviewer(s) think about you. So get used to feeling uncomfortable. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This would be a short version of my code:

You created CLibrary using the default constructor. mA is a null pointer.

@deceptikon
You may want to read an intro level tutorial to CPP
http://www.learncpp.com/cpp-tutorial/121-pointers-and-references-to-the-base-class-of-derived-objects/

Good. Now go to the next chapter and read about virtual functions, genius. I'd also appreciate if you reversed your negative rep on me when you eventually realize I'm right.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

@deceptikon
Your solution is wrong.
In your solution, when he calls print() it will treat all of the pointers as articles no matter what they are.

You might want to educate yourself a bit more before trying to correct people who actually know what they're talking about.

I also tried this, using an overloaded assignement operator defined for each one of the classes CArticle,CBook,CMagazine, but it breaks somewhere.

The overloaded assignment operator is irrelevant here because you're working with pointers at the container level. Please post a small but complete program that exhibits your problem and I'll see if I can locate the error.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

First and foremost, identifier names that are varying case from a keyword like CLASS, INT, or CHAR, are extremely bad ideas. I strongly suggest using something more informative.

To answer your specific question, pointers to class types work exactly the same way as pointers to built-in types. For example, when you increment a pointer to a class type, it skips over the size of an object of that class rather than skipping through the members. When you say *(POINTER + 2), you're trying to access memory that you don't own just as readily as if you had an array of 1 (CLASS a[1];) and tried to execute a[2]:

#include <iostream>

namespace {
    class Foo {
    public:
        int a;
        char b;
    };
}

int main()
{
    using namespace std;

    Foo obj { 123, 'a' };
    Foo *p = &obj;

    // The same address will be printed twice
    cout << p << ' ' << &obj << '\n';

    // The same value will be printed three times
    cout << *reinterpret_cast<int*>(p) << ' ' << obj.a << ' ' << p->a << '\n';

    // Please don't do this in real code
    cout << *(reinterpret_cast<char*>(p) + sizeof(int)) << '\n';
}

cout << endl << *POINTER << " " << OBJECT.INT << " " << POINTER -> INT; //WILL THESE SHOW THE SAME?

In this exact case, yes (with an appropriate cast on *POINTER). But you should be very careful when assuming the underlying structure of a class unless it's

nmakes commented: BTW, I just used them for easy readability of my post :) And I know it is a POD. But I just wanted to understand the meaning of the statements. :) And about the compiler, I'll definitely get one after I finish my school (My education board reccomends BC4. +1
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Option 1 would be preferred in this case. In option 2 you're allocating a whole new data structure to hold the filtered results and also iterating the original list in its entirety once followed by the filtered results once.

In option 1 you have what essentially boils down to a lazy evaluated yielding iterator. So it doesn't allocate any new data structures and only traverses the original list once (filtering out items that fail your predicate as it goes).

I'd expect option 1 to be faster as well as less wasteful of resources. But the compiler may optimize things such that the resulting difference is negligible.

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

The rules don't change just because you're nesting a control structure:

if (foo)
{
    if (bar)
    {
        // Blah blah
    }
}
else
{
    if (baz)
    {
        // Blah blah
    }
    else
    {
        // Blah blah
    }
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Ignoring for the moment that this is a horrible example of object orientation and brings into question whether you're qualified to be giving out examples as if you know what you're doing, what exactly is the benefit of an object oriented bubble sort here?

rubberman commented: Succinctly put D. :-) +12
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Besides, it is not part of the standard and your code might not work with other compliers. Before each scanf(), put fflush(STDIN); to make sure the input stream is empty.

Um...I hate to break it to you, but 1) C++ is case sensitive and STDIN is not a valid alias for stdin, and 2) fflush() isn't defined for input streams. So in one sentence you attacked non-standard code and then in the next sentence advocated non-standard code. ;)

Another thing to do is check the return value of scanf() which will tell you how many good values were read. If it does not match the number of variables that you were expecting, something went wrong; probably the user entered bad data.

Failure to check the return value of scanf() is probably one of the most common problems I see in beginner code.

David W commented: no need to be bashful ... it all needed to be corrected +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

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.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

do u think 1 hour is sifficient ?

Certainly not, but as you're hopefully not trying to deceive the interviewer, that's not your problem, is it? ;)

1.Why amazon ?

Why not?

2.what will you do if you get offer from google after getting offer from us ?

I'll do a cost benefit analysis and choose the offer that better suits my current career goals.

3.what are your weakness ?

I tend to oversimplify, and as such need to take special care to consider all possibilities when designing a solution so as to avoid missing something important but not obvious.

4.how can you contribute to amazon ?

The job description was specific about duties, was it not? While I'm sure I can provide significant added value beyond that, it's difficult to enumerate such things when the question is vague, and more importantly, broad. Could you be more specific about needs that aren't listed in the job description?

5.what do you expect from amazon/microsoft/....etc..?

Noting that as I've not worked for the mentioned companies, I try not to form expectations from a position of ignorance. However, I certainly expect the bare minimum of an employee/employer contract wherein I do my best to complete assigned tasks to the best of my ability and you compensate me fairly for that effort.

6.on what point do u get angry ?

Angry is ambiguous. Could you be more specific as to …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

how it is used and why we use it

In theory you would use it just like char, and the purpose is to support extended character sets. The char type for character usage was really designed and intended for character sets (and language alphabets) that can fit into a single byte, such as ASCII or EBCDIC.

In practice, conforming to larger character sets such as Unicode means you're targeting internationalization as a goal, which is quite a bit more complex than just swapping char for wchar_t. Even when you stick to a single locale, conversion between char and wchar_t is often necessary.

And also what is the difference between char and wchar_t.

char is guaranteed to be a single byte. wchar_t is a typedef for one of the integer types, and it may be multiple bytes so that it can represent any value in a large character set. You can't assume any specific size for wchar_t.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I created a service, it deletes files, but every so often, it cannot delete a file.

In cases like this, rather than try to find a sweet spot for timing, I'll simply add the failed paths to a collection and retry later during a global cleanup operation. Most likely it's not imperative that these files be deleted immediately, so if they fail due to being in use, it's probably fine to postpone.

I still feel that 3 seconds is to short for mine.

Then use a larger value for retries. Once again, this is precisely why I made it a method parameter instead of hard coding it to 3. 3 has worked for me in the past, but I'm not naive enough to believe that it's the perfect value for all occasions.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You can use a va_list twice, provided it's properly disposed of with va_end() and re-initialized with va_start() or copied with va_copy(). What you can't do is assume that va_list represents a bidirectional read-only collection. It could easily be a generated array or list of arguments that are modified or destroyed after processing with va_arg.

nitin1 commented: nice one!! +2
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i tried to free()mem i allocate in prog using malloc

But you don't. You try to free the result of fun(), which is a pointer to int that corresponds to the address of x in main(). In other words, you're trying to free something that should not be freed. The problem is here:

// Memory is allocated to num, all is well
int *num = (int*)malloc(sizeof(int*));

// The memory allocated above is leaked away and now num points to TX,
// which is a pointer to x in main (*not* a pointer to dynamic memory)
num=(int*)TX;

At this point you already have a memory leak, and any attempt to free num or any reference to num will fail miserably because the pointer was not previously returned by malloc(), calloc(), or realloc().

Remove that second line as it's wholely unnecessary in the first place. What you probably wanted to do is this:

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

void *fun(void *TX)

int main(void)
{
    void *exitstat;
    pthread_t t;
    int x = 50;

    pthread_create(&t, NULL, fun, &x);
    pthread_join(t, &exitstat);

    printf("%d\n", *(int*)exitstat);
    free(exitstat);

    return 0;
}

void *fun(void *TX)
{
    int *num = malloc(sizeof *num);

    *num = *(int*)TX;
    *num += 10;

    return num;
}

Why are you freeing TX?

While correct, that's not informative.

ddanbe commented: Respect! +14
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but still can you tell me the way in which it is mostly implemented ?

rand() is usually implemented with some form of linear congruential generator.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Given that "how to develop software" is extremely broad, I'll answer the specific question you asked.

how can i make the program to remember the value the user assigned to its variables without erasing it everytime i close the exe file running the program??

Persistant data would be saved to the hard drive or some other semi-permanent storage and then loaded back into memory when the program is run again.

pbj.codez commented: you said it in a fancier fashion then I ever could. nice +2
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yeah...no.

A pointer to void is a generic object pointer, it can point to any object type (but not a function pointer type). For example, the following code has no errors:

void foo(void *p) { }

int main(void)
{
    int *a;
    char *b;
    double *c;

    foo(a);
    foo(b);
    foo(c);

    return 0;
}

int*, char*, and double* are all compatible with void* and can be safely converted to void*. Likewise, in C a void* can be implicitly converted back without a cast. That's why you don't need to cast malloc() even though it returns a pointer to void:

char *p = malloc(10); /* No cast needed! */

The reason I asked about void* and void** is to introduce you to this subtle little error:

void foo(void **p) { }

int main(void)
{
    int **a;

    foo(a);

    return 0;
}

The "genericalness" no longer applies. p is a pointer to a pointer to void, not a pointer to a pointer to some undisclosed object type. Therefore int** is not compatible, and the only type you can pass into foo() is a void**.

The reason I gave you this question is because const has somewhat similar behavior. You can convert int* to const int*, but int** and const int** are incompatible for the same reason as with void* and void**. The added level of indirection is the culprit.

Tumlee commented: Excellent explanation. +5
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

C# is a Microsoft specific language and relies on the Microsoft compiler, so your options are very limited.

.NET is a Microsoft specific implementation of the CLI that includes C#. C# is an internationally standardized language whose evolution is driven solely by Microsoft presently, but there's nothing stopping someone from writing a compiler for it. If nothing else, the existence of Mono belies your statement that C# relies on the Microsoft compiler.

I'm curious why the OP wants to exclude Visual Studio.

Ketsuekiame commented: Good point about C#, was just trying to simplify. As you say, it's pretty much solely driven by MS. +9
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

Paragraph 15.3.15 of the standard: "The currently handled exception is rethrown if control reaches the end of a handler of the function-try-block of a constructor or destructor."

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Design and code a program in c that converts time in seconds to hours, minutes and seconds and display the results.

I'm done, but I don't have your teacher's email so that I can turn it in for a grade. Could you post that, please?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

undefined and implementaion dependent, both are not defined by C standard ?

Undefined means all bets are off, the program could do anything and has no restrictions, nor does it have to behave predictably. Implementation-defined means the compiler must choose a predictable behavior and document it, even if the standard doesn't provide options on what the behavior might be.

Further, unspecified means that the compiler must choose a predictable behavior but doesn't need to document it.

i have read somewhere that malloc may use sbrk() in which when we pass 0

sbrk() is a Unix-ism. Talking about portability while also depending on a specific underlying implementation is silly.

can you please give one more example to exemplify the difference between these 2 things ?

I'm not sure I understand what you want to see. Which 2 things need further example?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

rather than needing multiple people in both permanent and contract positions, actually they aren't recruiting anyone at the moment.

Was this a large corporation? That would still be sad, but a bit more understandable than a smaller company.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I was asked this in an interview today:

Q: malloc(0); /* What does it do? */

It's a great question because it covers a subtlety in the standard and a condition that not many people will consider. Unfortunately, I wasn't 100% confident that I remembered what the standard said about it. With full understanding that I brought the question on myself by arrogantly describing myself as an expert in C, I gave my answer as follows: "A valid pointer will be returned, but that pointer cannot be dereferenced."

My answer was wrong. The interviewer said that the result was undefined behavior, which seemed slightly off to me at the time though I didn't challenge him on a nuance I wasn't assured of. As it turns out, my answer was partially correct, though in being partially correct it was still wrong. However, the interviewer wasn't correct either. The standard states the condition of a zero size request as follows:

"If the size of the space requested is zero, the behavior is implementation-defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object."

Note that implementation-defined is very different from undefined. Undefined means that the very act of calling malloc(0) invokes undefined behavior and as a result makes the entire program henceforth undefined as well. Implementation-defined means that malloc(0) is legal and doesn't affect the legality of the rest of the …

nitin1 commented: awesome!! learnt something new!! +2