deceptikon 1,790 Code Sniper Team Colleague Featured Poster

for example by adding \" it interprates " as a string then why cannot we use \ in our case?

Because escape characters are interpreted at the compiler level and format specifiers are interpreted at the library level. If \% gave you a literal '%' then it would still be treated as the opening character for a format specifier by the library code. Further, even though the library could be specified to use \%, it would have to actually look like this in user code:

printf("How are you \\%dad\\%");

And the reason is because the compiler will try to interpret any escape, so you need to escape the escape opening character to get a literal '\'. In other words, it's awkward either way, so printf()'s designer took the wiser route, in my opinion, and simply made a format specifier for a literal '%'.

It's probably a little advanced, but you can see a working implementation of printf() here:

http://code.google.com/p/c-standard-library/source/browse/src/internal/_printf.c#35

And the format specifier parsing is done in this function:

http://code.google.com/p/c-standard-library/source/browse/src/internal/_fmtspec.c#128

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

GCC doesn't support void main, therefore any use of it invokes undefined behavior. More specifically, if the compiler doesn't support void main then the code it produces could be very wrong or dangerous.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The following is completely unnecessary:

pina=NULL;
pinb=NULL;
pinc=NULL;

free(pina);
free(pinb);
free(pinc);

Calling free() on a null pointer is a no-op, and because you immediately call malloc() for each of those pointers, there's really no purpose in setting them to NULL to begin with.

A glaring problem is that you allocate essentially a 1D array, but then treat it as if it were a 2D array. That's a big no-no, and it's almost as if you're mixing two different methods and breaking them both in the process. Your first initialization loop should look more like this to properly simulate a 2D array (error checking omitted for brevity):

int **pina, **pinb, **pinc;
int i, j;

pina = (int**)malloc(m * sizeof(int*));
pinb = (int**)malloc(m * sizeof(int*));
pinc = (int**)malloc(m * sizeof(int*));

for (i = 0; i < m; i++) {
    pina[i] = (int*)malloc(n * sizeof(int));
    pinb[i] = (int*)malloc(n * sizeof(int));
    pinc[i] = (int*)malloc(n * sizeof(int));
}

Also don't forget to free the inner dimensions. All in all, a fixed add() would look something like this:

void add(int m, int n)
{
    int **pina, **pinb;
    int i, j;

    pina = (int**)malloc(m * sizeof(int*));
    pinb = (int**)malloc(m * sizeof(int*));

    for (i = 0; i < m; i++) {
        pina[i] = (int*)malloc(n * sizeof(int));
        pinb[i] = (int*)malloc(n * sizeof(int));
    }

    printf("Give elements for A: ");
    fflush(stdout);

    for (i = 0; i < m; i++) {
        for (j = 0; j < n; j++)
            scanf("%d", &pina[i][j]);
    }

    printf("Give elements for B: "); …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I already posted in my post that i know this solution of implementing it in one cpp file

Header files are a glorified cut and paste mechanism. If you're having trouble with your headers, then manually creating the same effect in a single file can help highlight the problem. You said you fixed it by using a single file, but clearly you made some sort of change that differs from how your compiler would have done it, otherwise the error would persist even using a single file. Here's how the translation unit would look with your headers directly included:

#include<iostream>
using namespace std ;
class FileOne ;
class FileTwo
{
public:
    int Test(FileOne One){
        return (One.var1+One.var2);}
    FileTwo(void);
    ~FileTwo(void);
};
class FileTwo ;
class FileOne
{
private:
    int var1 , var2 , var3 ;
public :
    friend int FileTwo::Test(FileOne One);
    FileOne(){
        var1= 12;var2 = 24;
    }
};
int main(){
    FileOne one ;
    FileTwo two ;
    cout<<two.Test(one);
}

The error is still present, and it's much easier to see now that everything is all together in one file. Once you fix the error in a single file, you can break it back up into multiple files. And in this case, the fix is to separate the member function declarations from their corresponding definitions (ie. use a header/implementation file setup).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

When you forward declare a class, you only tell the compiler that it exists, not what's in it. So while the declarations are fine, the definition of FileTwo::Test() would need to be deferred until after both classes have been introduced completely:

class FileOne;

class FileTwo
{
public:
    int Test(FileOne One);
};

class FileTwo;

class FileOne
{
private:
    int var1, var2, var3;
public:
    friend int FileTwo::Test(FileOne One);

    FileOne()
    {
        var1 = 12;
        var2 = 24;
    }
};

// Now this definition will work
int FileTwo::Test(FileOne One)
{
    return (One.var1 + One.var2);
}

#include <iostream>

using namespace std;

int main()
{
    FileOne one;
    FileTwo two;

    cout << two.Test(one) << '\n';
}

To facilitate this with multiple files and headers, I'd suggest separating your class declarations and definitions into a header and implementation file. First the header:

// FileTwo.h
#ifndef FILETWO_H
#define FILETWO_H

class FileOne;

class FileTwo
{
public:
    int Test(FileOne One);
};

#endif

Then the implementation file which handles definitions:

// FileTwo.cpp
#include "FileOne.h"
#include "FileTwo.h"

int FileTwo::Test(FileOne One)
{
    return (One.var1 + One.var2);
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

A function prototype is also called a function declaration. You supplied a function definition.

A definition is also a declaration, but a declaration is not always a prototype. A prototype is the very specific declaration without a body that defines parameters (excluding the case of an empty parameter list), also referred to by the standard as a "prototype declaration":

void foo(void); // No arguments
int max(const int a, const int b);

A prototype-like declaration with empty parentheses is not a prototype:

void foo(); // Declaration (unknown arguments), not a prototype

Definitions introduce a declaration, but follow the same rules and only introduce a prototype if the declaration alone would do so:

// Definition (no arguments), also a prototype (no arguments)
void foo(void) { }

// Definition (no arguments), also a declaration (unknown arguments), not a prototype
void bar() { }

kw42chan's code was correct as far as technically introducing a prototype even though it was done through a definition. But I suspect that it's not correct in terms of the spirit of the assignment, which is to write a prototype independent of the definition:

int max(int a, int b); // Prototype

int main(void)
{
    ...
}

int max(int a, int b) // Definition
{
    ...
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

While I don't disagree that VBA is missing a solid home, I'm not convinced that we need to add a new forum when VBA threads can be tagged as such and placed in a forum that's "close enough" and likely to be seen by fellow VBA peeps.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster
tux4life commented: Yuppers ;-) +13
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

.NET programs aren't compiled to machine code as part of the assembly, they're in an intermediate state (IL assembly language) that the framework needs to compile into machine code. On the first run of an assembly, the just-in-time (JIT) compiler does all of that, which is why it's slower than subsequent executions.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Thank you! I'm feeling so stupid...

17 years programming C and I still make that particular mistake (ie. using = instead of ==). No worries, it's a common and easy one to make. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The "console screen" isn't unique to Turbo C. Your suggestion is still very poor and makes unwarranted assumptions about the OP's compiler and operating system.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

At this point I've lost interest in helping you because you keep asking essentially the same question and have still shown absolutely zero effort. I suspect nothing will come of this project and as such don't feel like wasting my own time designing it for you.

But one last time before I abandon the thread: Figure out what you want the system to do, then write code that does it. If you don't have any clue how things are supposed to work, writing software to do it is impossible.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm unable to update our production server, so at the very least we'll need to wait until Dani wakes up. But it looks like there was test code in recent changes that fell through the cracks and needs to be rolled back. It should be a quick fix if that's the problem.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I see a possible issue in recent code changes, but until Dani wakes up we can't confirm it or update production. Just sit tight for maybe another hour and things should be resolved.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

this means the function will exept a pointer and it is a IntPtr type.can you tell me how it is equivalent to a double pointer ???

IntPtr is defined as

typedef int* IntPtr;

The second asterisk is hidden by the typedef, so IntPtr* becomes int** when evaluated. Your confusion on the matter is precisely why I generally recommend against hiding levels of indirection with a typedef.

tux4life commented: Agree. +13
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

according to you, contests don't improve a person ?

I didn't say that. But contests do require a unique skillset that isn't directly applicable to the real world, in my opinion. You can derive several skills for real world projects from the skills learned doing contests, but if you treat real projects like a contest I can guarantee you'll find yourself fired in short order. Conversely, the practical techniques used in the real world will consistently fail to do well in any kind of contest.

And more specifically, because I'm sure you'll ask the same question again: my immediate supervisor was a regular winner of programming contests in his college years, and he definitely thinks they were a valuable experience. So yes, doing contests is good for you, but don't trick yourself into thinking that just doing contests will make you a good professional programmer.

nitin1 commented: awesome explaination! can't get this wording from anybody who is in contact of me :-) +2
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Pick any language you're comfortable with. I assume because this thread is in VB.NET that you want to use VB.NET, and that's a perfectly suitable choice. Seriously dude, if you need confirmation from someone else that every little decision you make is okay, this project will take you approximately forever plus one day.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

so deceptikon its that i should bring the barcodes from outside that is not through coding and just do coding of the inventory....u are saying like this no....?

Yes, that's roughly what I was saying.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I think getting more into it would just confuse you further. Const correctness can be tricky, so it's probably best to just accept this example as an exception to the rule, handle errors as they arise, and wait for a little more experience to faciliate that "aha!" moment.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Constness of a member function only applies to the direct state of the object for its class, so it's completely irrelevant if the non-const hello calls a member function that changes its own state and not the state of hi. It would be different altogether if you tried to change where hello points because that's hi's direct state. It would also be different if hello itself were const, because Test() isn't const qualified. Finally, it would be different if hello were not a pointer because then the state of hello would be a subset of hi's state.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

can you say some thing about it....

Oh the things I can say about it. I've written production software for this exact problem before. ;)

Anyway, is this a real application? Like are you actually going to implement it in a retail store in the real world? Or is this more of an exercise or school project? Because if it's real then you'd be so much better off using existing software and hardware to get the job done:

  1. A barcode sticker printer
  2. Barcode generator software for the printer.
  3. Handheld barcode readers and/or in-counter readers for checkout.
  4. Retail software for inventory lookup.

The barcode part stops after it's scanned because the result will be an inventory item number or UPC/EAN number (most likely the latter). That number is sent to the retail software for lookup and inventory management.

Writing your own VB.NET application to do this would be prohibitively expensive both in terms of development cost and maintenance (not to mention problems caused by bugs and whatnot) compared to the relatively minor cost of purchasing software that already does what you want.

If it's a project that won't be used in the real world then it's much easier to simulate a retail store and its barcoded inventory system.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

main part is how we sort it so as get the bext complexity possible.

You still don't have the best complexity possible. I find it somewhat amusing that you describe your solution as "easiest" and "poor", then complain about the performance of simpler solutions after practically demanding that someone else prove they can solve the same problem. :rolleyes:

for all contests, this approach is much.

Contests require an unreasonable focus on performance. If you want responses that fit into that niche area then make it very clear that your goal is to win contents and not solve a realistic problem.

using bubble sort will give time limit exceeded

Clearly you didn't read the comments that I so carefully included in the code.

nitin1 commented: you are awesome, you are strict and you also teach well. :-D thanks a lot to you +2
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i dont want any more negative votes to my code.

Your snippet has only one vote. Did you post the code to help others or did you post the code to get an ego boost? Seriously, if you're afraid of negative feedback then you shouldn't put your stuff up for public display. On the other hand, if you're interested in improving yourself then negative feedback is by far the most productive, even if it cuts your ego down to size.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I Just wanna know what happens if we try to do the following in C++: "abc"+'d'

In that particular case, you'd overrun the "abc" array by indexing it beyond the null character at the end. However, whether this is a problem or not depends on how you use the result.

So what's happening? "abc" is converted to a pointer to the first element. Then 'd' is interpreted as an integer value and added to that pointer. The result is the same as any pointer arithmetic of the form p + n. But because "abc" doesn't have enough characters to handle pointer arithmetic beyond p + 3, and (int)'d' is surely much larger than that, you risk undefined behavior.

This is the test program you should have written:

#include <iostream>

int main()
{
    std::cout<< "abcdefg" + 4 <<'\n';
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

After doing some research I'm confused about why you would use these instead of normal SQL query.

Separation of the query and data is a primary method of defending against SQL injection attacks. There are other reasons for using prepared statements, but since your concern is security, that's basically it.

falsely suggests that no sanitisation of data is needed - completely ignoring other attacks such as XSS, file inclusions etc.

Only if you don't understand what the point of prepared statements is, but it's a valid point that some people will think that handling injection attacks is enough, or assume that by using a library all other possible attacks are mitigated as well. That's less of an issue with the library than it is an issue with the programmer though. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I wouldn't recommend using strtok() in this case because it modifies the string by way of inserting null characters at the end of each token. This effectively destroys the string for your purposes, so unless you're working with a copy, it's best to stick with a little bit more manual method:

#include <cstring>
#include <iostream>
#include <string>

size_t find_word(const char *s, const char *word)
{
    size_t len = strlen(word);

    for (const char *p = s; *p; ++p) {
        if (strnicmp(p, word, len) == 0)
            return (size_t)(p - s);
    }

    return (size_t)-1;
}

int main()
{
    std::string line, word;

    std::cout<<"Enter a line of text: ";
    getline(std::cin, line);

    std::cout<<"Enter a word to find: ";
    getline(std::cin, word);

    size_t index = find_word(line.c_str(), word.c_str());

    if (index == (size_t)-1)
        std::cout<<"'"<< word <<"' was not found\n";
    else
        std::cout<<"'"<< word <<"' is at index "<< index << '\n';
}

Note that I didn't do anything to replace since you only asked about finding the index of the word in question. I assume you already have ideas for doing the replacement once you have that index?

Also note that stricmp() and strnicmp() are not standard functions, so a compiler isn't required to implement them. However, since you used stricmp() in your code, I'm assuming your compiler does implement them.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Oh the shattered hopes and dreams... :)

I'm pretty sure it's in my Daniweb contract somewhere that I have to crush dreams on a regular basis.

<M/> commented: Hahaha :) +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

@deceptikon, please update or allow Michael to upload an animated pic. anything to swap out that horrendous avatar that he currently has that looks like a cross between a Chihuahua and an an Ostrich. lol...

Haha! But seriously...you think that thing would be better animated? O_o

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is there a way to change your avatar into an animated avatar?

No. When you upload an avatar, we resize it internally to ensure that it's 80x80, and the method we use to do that only returns the first frame of an animated image.

I have seen a few avatars that are animated... Know how to upload one?

Most likely you've seen avatars that were grandfathered in during the migration from vBulletin to the current system. That would have side steped our upload process, but it doesn't help you now because the only way to get an animated avatar if you didn't already have one would be to edit the database manually.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

toMakeFood doesn't exist because everywhere you have a declaration of it, you're saying "defined elsewhere" due to the extern keyword. Add an includes.c file with this:

bool toMakeFood = false;

And don't forget to link that file in with the rest. The header will provide multiple delcarations while the .c file will provide a single definition. On a side note, I strongly suspect you're compiling as C because bool and true/false require the inclusion of the stdbool.h header.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'd mention that the code works on my end and ask how they're testing it on their side. Make it clear that you respect their decision to halt the interview process and that you're most interested in learning what you may have done wrong.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The compiler is right. You declare copies without initializing it, then immediately try to print its value. That's undefined behavior, and constitutes a bug.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Good luck with that. I hope you realize that you failed to provide enough information for anyone to help you.

Begginnerdev commented: That too! lol +6
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

could u can plzzz,,,,,,,,,,,......

No. Do your own damn homework, and if you have a specific question or difficulty that doesn't amount to "I'm lazy, gimme gimme gimme", we'll be happy to assist.

NathanOliver commented: I guess it is to hard to read the rules +10
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well you can forget about the pronunciation. The most important is that you can see what they are doing.

Watch a video tutorial with the sound off and see how useful it is. ;) Honestly, if that works out then the video didn't need to be a video in the first place.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I dont use memcpy often

As well you shouldn't. memcpy() is a very low level function that was inherited from C. The problem with memcpy() in C++ is that it doesn't respect class structure or construction/destruction, so unless you have what is called a POD type, use of memcpy() is undefined. My usual recommendation is to forget memcpy() exists unless your code is C compatible.

The usual shallow copying problems present in C were also inherited, such that if you copy a pointer, only the address gets copied and not whatever the pointer points to. That results in an alias that, when unintended, wreaks havoc on memory.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

p_array is a pointer. When you use the subscript operator, that pointer is dereferenced. In other words p_array[index] is functionally identical to *(p_array + index). Now, when you dereference p_array, the result is also a pointer, specifically a pointer to char. So this line is correct because the %s specifier of printf() expects a pointer to char:

printf("%s\n", p_array[index]);

If you further dereference the pointer, you get a char value (not a pointer). The reason you're getting an access violation is because printf() treats that value as an address, because you told it using the %s specifier that you were providing a valid address in the form of a pointer. In other words, you lied to printf(). ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Debugger shows this as 1515804759 in Decimal. that is when 5958595a taken as a whole.
why doesn't it show 87888990 like when they are take separately?

Because eax is being interpreted as an integer value instead of an array, so all four bytes are a single entity totaling to 1515804759 rather than separate entities {87,88,89,90}.

Why is it shown as 5a,59,58,57 rather than 57,58........ ? (because W=57 which comes first)

Endianness

and why is it 5A after the 59 in hex? (I know that 10 is A,11 is B etc..... but not this)

Um...what? You know that A comes after 9, so how is 5a after 59 confusing? The rules of the positional numbering system don't change just because there are more significant digits present. The jump to 60 doesn't happen until after F, because hexadecimal has 16 distinct values per digit place: 59, 5a, 5b, 5c, 5d, 5e, 5f, 60.

It seems like you're stuck in a decimal mindset. The only reason 10 comes after 9 in decimal is because there aren't are only ten values that can be represented by a single digit: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. If you add more values, the need for 10 is delayed. If you remove values (such as in octal or binary) then the need for 10 is accelerated. If you think about 10 being the value that happens when you run out of unique single …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I thought Visual studio 2010 compiler is not open source therefore I won't be able to find thoses files there

These are template classes. Without getting too much into it, due to the way templates are implemented, it's drastically more efficient to keep all of the code together rather than separating declarations and definitions. So template classes are nearly always implemented fully in the header file. Provided the header is actually stored as a viewable file, you can look at the code.

Isn't 'iostream' a part of the c++ library? why do some people call the <iostream> a library, not a file of the standard libarary?

Because everyone knows what you mean when you say the iostream library, there's no ambiguity. Why waste time with a pedantic description when there's no need? There may also be a historical reason, where there were originally many different libraries (of which iostream was one), and they were basically collected into the current "standard" library.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

1.If cin and cout objects are in the 'iostream' , why do we need to declare it again using 'std' ?

<iostream> is the header that contains declarations. Without those declarations your compiler doesn't know that the names you use exist. The names themselves are declared within a namespace to avoid collision with other libraries.

Headers and namespaces are not used for the same purpose. In this case you're "declaring" namespace std to save you the trouble of constantly using the fully qualified name each time. Otherwise you'd end up typing std::cout instead of just cout.

2.are cout,cin,cerr,clog the only ones in the iostream?

Yes (including wide counterparts). But keep in mind that there's a metric shit ton of scaffolding behind those objects, which you'll find in headers such as <ios>, <istream>, and <ostream>. <iostream> is conceptually just the header that defines the objects cout, cin, cerr, and clog. But those objects have types which are defined in other headers.

The <iostream> header can be as little as this:

#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>

namespace std {
    extern istream cin;
    extern ostream cout;
    extern ostream cerr;
    extern ostream clog;

    extern wistream wcin;
    extern wostream wcout;
    extern wostream wcerr;
    extern wostream wclog;
}

3.under which categories do cin,cout and iostream fall? (library,object etc..)

cin and cout are objects in the standard I/O library.

4.can we use the same iostream for both linux and windows? how come?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

@deceptikon
I would like to read your opinion on comparison of java and .net

I'm not confident that I could provide a good comparison, even if you offered specific scenarios. My expertise in .NET is a full revision behind and my knowledge of Java is even more outdated.

if career in .net is not bad option then chances of learning java will decrease by 10%

Having at least a basic understanding of both would be the ideal situation, but both Java based development and .NET based development are viable career paths.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I am so happy I've quit .Net because Java is really fun !!! :-)

I'm happy that you're happy, but it's obvious that most of your bullet points for why Java is better are heavily opinionated to the point of propaganda. Some are off topic (eg. Tomcat being "better" than IIS), correspond to points that could be made equally for .NET (eg. "cool embedded stuff" and a "nice sound API"), or are just completely irrelevant (a cool mascot?). Even the ones that are legitimate reek of bias.

A proper comparison should be completely objective. The person doing the comparison should focus on specific needs (because obviously these two general solutions won't apply equally in all cases), and should be an expert in both so as not to skew the comparison with ignorance. Anything else just ends up being "I like XYZ, so you should like it too".

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You've cut and pasted parts of the code but neglected to modify everything. For example, in the file_w part of the code you're still working with fileread rather than filewrite. Compare and contrast with this corrected code:

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

int main(void)
{
    FILE *file_r, *file_w;
    int c;
    char fileread[40];
    char filewrite[40];

    printf("Enter filename to be copied: ");
    fgets(fileread, 40, stdin);
    fileread[strlen(fileread)-1] = '\0';
    file_r = fopen(fileread, "r");

    while(file_r == NULL)
    {
        printf("Invalid file, ealnter again!");
        fgets(fileread, 40, stdin);
        fileread[strlen(fileread)-1] = '\0';
        printf("%s\n", fileread);
        file_r = fopen(fileread, "r");
    }

    printf("Enter name of file copy");
    fgets(filewrite, 40, stdin);
    filewrite[strlen(filewrite)-1] = '\0';
    file_w = fopen(filewrite, "w");

    while(file_w == NULL)
    {
        printf("Invalid Filename enter again");
        fgets(filewrite, 40, stdin);
        filewrite[strlen(filewrite)-1] = '\0';
        file_r = fopen(filewrite, "w");
    }

    c = getc(file_r);

    while(c != EOF)
    {
        putc( c, file_w);
        c = getc(file_r);
    }

    fclose(file_r);
    fclose(file_w);
    printf("Files succesfully copied");

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

The comparison delegate returns an integer denoting the relation between the two objects: 0 for equal, -1 if x is "smaller", and +1 if x is "larger". So it would be more like this:

Private Function SortMyList(ByVal x As MyType, ByVal y As MyType) As Integer
    Dim tsX As TimeSpan = x.dEnd.Subtract(x.dStart)
    Dim tsY As TimeSpan = y.dEnd.Subtract(y.dStart)

    If tsX < tsY Then
        Return -1
    ElseIf tsX > tsY Then
        Return 1
    Else
        Return 0
    End If
End Function

Assuming this is how you want to compare the timespans, of course.

Begginnerdev commented: Thanks Deceptikon! +6
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

hmmm~ just means the word can always be stay at the twinkling stage.

You're explaining what "twinkling" means by using the word "twinkling", do you not recognize how unhelpful this is? It's like saying that twinkling is when something twinkles. When we don't know the fuck what you mean by "twinkle", any use of "twinkle" in your explanation of "twinkling" is COMPLETELY MEANINGLESS.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

A static member is shared between all objects of the class whereas each object of the class contains a copy of the instance member. It's really as simple as that, though the static keyword is heavily used for different purposes in C++.

LearnCpp - Static Members
IBM Reference - Static Members

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Note that this is a dual feature, and the second part makes the first part less useful. If we implement some sort of notification that people are online, we'll also need to include a way to disable it and allow people to be invisible. Otherwise it has too much of a "Big Brother" feel.

Honestly, while I did find it interesting to see whether someone was online, I myself chose to be invisible. Honestly, I'm not sure whether that feature makes sense for Daniweb or if it would be nothing more than feature matching to compete with other forums (which I don't think we need to do).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i said that solution above is general :D

And I implied that your solution is brittle. ;D

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The problem is that it's my first project of its kind and i don't know how to start also the defregmant part is a bit tricky

So you haven't been given any projects in the entire course? This is the final project, which means you can't play the clueless card.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You're aware that this is the very first program anyone learning assembly will have to write, and it's ALWAYS provided in toto by the teaching resource (ie. book, website, or course notes), right?

So either you're lazy to the point that shocks even me, or you need to ask a more specific question.