Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

get yourself one of the free 32-bit compilers and call win32 api functions

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is still a really big problem for me -- it takes a full 30 seconds to load a page in the mod-only forums. Page loads are ok in c and c++ forums. Makes it impossible to perform any mod duties.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can't really delete an element from an array, about all you can do is blank it out.

int main()
{
	string names[7] = { "jim", "mag", "narelle", "jim", "helga", "mag", "kim" };
    int asize = sizeof(names)/sizeof(names[0]);

	for (int i = 0; i < asize; i++)
	{
        if( names[i] == "")
            continue;
		for (int j = i+1; j < asize; j++)
		{
			if( names[i] == names[j] && names[j] != "")
			{
				names[j] = "";
			}
		}
	}
    for(int i = 0; i < asize; i++)
    {
        if( names[i] != "")
            cout << names[i] << "\n";
    }
	return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

delete lines 21-25 because that is just meaningless crap.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just a guess, but if you are trying to read the contents of a structure perhaps there are holes in the structure, such as the packing factor is something other than 1.

#pragma pack(1)
struct mystuff
{
   WORD a;
    DWORD b;
   // etc
};
#pragma pack()
Intrade commented: Expert analysis +1
Salem commented: *nods* +35
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

in my f..king third world home, we have a mandatory military attendance which i havent done yet.

Well, what's stopping you? Go get it overwith, military will make a man out of you. We had that too when I was your age, and I stayed for 23 years :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Time type

Type capable of representing times and support arithmetical operations.

This type is returned by the time function and is used as parameter by some other functions of the <ctime> header.

It is almost universally expected to be an integral value representing the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC. This is due to historical reasons, since it corresponds to a unix timestamp, but is widely implemented in C libraries across all platforms.

http://www.cplusplus.com/reference/clibrary/ctime/time_t/

Dave Sinkula commented: "almost", much like "non-portable", is pretty much what I've been saying. -4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> pointless post - cartman714
You obviously have no clue about what I posted.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can find all the unicode version of standard functions by googling for the function then selecting the MS-Windows version in the google links.

For programs I'm going to use just for myself I always turn UNICODE off so that I don't have to bother with the macros. You should do the same for code you are writing for university classes unless your professor tells you otherwise he/she wants UNICODE ready code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>what amount of time as a software developer are we supposed to spend being with computer?

24/7 :)

If you are in school and trying to work full-time too then your love like will suffer greatly. Take small vacations away from work frequently to help avoid burnout. And don't forget to go home at least once a year to visit family.

tux4life commented: Is that with Christmas then :P ? +9
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How did you create this new thread ?

He originally hijacked another thread, and we (Happygeek) moved his post here.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I am currently having a lot of problems too when attempting to do mod stuff, like list all member's posts. All I get, when it finally finishes, is a blank screen with "done" in the status box at the bottom of the browser's window. Yesterday I was able to click Refresh and get the expected output, but now that won't even work.

Just tried it with IE8 and it has the same issued. Very very slooooow

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can not just typecase from char* to wchar_t*. You have to call one of the transformation functions.

This works ok for me when the program is not compiled for UNICODE

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
char S1[] = "C:\\Program Files" ;
char S2[]= "Zebra";
strcpy(S1,S2);
cout << S1 << "\n";
}

And the UNICODE version

#include <iostream>
#include <tchar.h>
using namespace std;
#ifdef _UNICODE
#define COUT wcout
#else
#define COUT cout
#endif
int main()
{
    TCHAR S1[] = _TEXT("C:\\Program Files") ;
    TCHAR S2[]= _TEXT("Zebra");
    _tcscpy(S1,S2);
    COUT << S1 << _TEXT("\n");
}

With the above code you can compile the program with our without UNICODE and the compiler will make appropriate conversions for you.

If you are not really interested in UNICODE then just turn it off and code normally as in my first code snippet. To turn it off select menu item Project --> Properties --> Configuration Properties --> General. Then on the right side of the screen change the "Character Set" list box to "Not Set".

Creator07 commented: Thanks for the quick help +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have to use some of the Windows Console functions. But they are not available if you are using an ancient 16-bit compiler. If that is true then upgrade to a new free 32-bit compiler, such as Code::Blocks or VC++ 2008 Express.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1. Read the value at that registry setting. If you are using non-managed code (normal c++) then you can refer to any of these links for more information.

2. Assuming it is a path to a file, just use standard C function remove() to delete it.

3. You will also want to remove the path and filename from the registry entry to indicate it no longer exists. That prevents leaving orphaned entries in the registry.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is one way to retired the output of that program to a file. If all you want is to get it into your program then do the same thing here buf save the strings in an array or vector<string>

#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    char buf[255] = {0};
    FILE* fp = 0;
    fp = _popen("C:\\Windows\\System32\\ARP.exe -a","r");
    if( !fp )
    {
        cout << "_popen() failed\n";
        return 1;
    }
    ofstream out("mel.txt", ios::trunc);
    if( !out.is_open() )
    {
        cout << "can not open mel.txt\n";
        fclose(fp);
        return 1;
    }
    while( fgets(buf, sizeof(buf), fp) != NULL)
        out << buf;
    fclose(fp);
    out.close();
return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>while(desktop = NULL);
That will produce an infinite loop because you want to use the boolean == operator, not the assignment = operator.

And what's the point of those do loops anyway? If FindWindow() returns NULL the first time it will always return NULL. Calling FindWindow() again isn't going to change the return value.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Hiii


How to use SHFileOperation() ?

u have any direct link to it...

thanking u..

You mean like this one?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

IMO C and C++ are poor languages for doing web stuff. It will be a lot simpler to use a language that is suited for that kind of programming.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Those binaries are not instealled with the operating system, so you have to get them from the compiler's installation directory. Since you are creating your own compiler/linker you too will have to install those libraries with your compiler. I don't know how compiler makers such as GNU get those libraries -- maybe they have to buy a license from Microsoft. The same for STL and other standard C/C++ libraries.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why would you want to do that? Just use Code::Blocks and you have it done, and probably much better too. And Code::Blocks contains a debugger, which Notepad++ does not.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Use which ever language you like the best. If you download the DirectX SDK from M$ it contains several example programs and I think they are written in c++.

>>Also is the mouse in windows written in c or C++?
There are no win32 api functions written in C++. M$ coders may have used c++ somewhere in the operating system, but all functions exposed to the outside world are C.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

no,this is a C language program,i test it,this code is run,but don't work correctly,i don't know why work incorrectly!confused

No you didn't because it will not compile. And C programs do not contain calls to cout, which is a c++ class from iostream. So you really have no clue what you are doing, do you? And you apparently (obviously) didn't write the code you posted but copied it from somewhere else.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That is a c++ program and contains millions (well, maybe not quite that many) errors. You need to get yourself a good modern compiler that does not use iostream.h but <iostream> (no .h extension), such as Code::Blocks or VC++ 2008 Express, both are free.

I'm not about to do your work for you, like debugging that program. That's your job, not mine. All you have to do if fix the errors one at a time, then recompile to see what errors are left to fix.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

this is not a C program because it includes iostream.h, which is an old obsolete file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>that rather than doing it the "right" way, the "easy" way was chosen?

You consider calling a function just to subtract two numbers is the "right way":icon_eek: What a waste of cpu time.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just as I thought -- you have to move that function into a *.cpp file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Post your header file. I suspect you are putting executable code or declaring objects in it. You can't do that. If you want to put an integer in the header file then you have to declare it with the extern keyword so that the compiler knows to look in a *.c or *.cpp file for it. extern int foo;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>difftime()

I see absolutely no value in that function because all it does is subtract the two parameter values and return the result as a double. When time_t is an (unsigned)integer then the double return value is just plain inconvenient because it would have to be typecast back to time_t. So the program might as well just subtract the two time_t objects and be done with it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Possibly lack of code guards is the problem.

#ifndef MYHEADER_H
#define MYHEADER_H

// other stuff here
#endif

[edit]what ^^^ said [/edit]

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>four words or two
Two. Punctuation marks are not considered words. None of the solutions presented so far in this thread would parse that sentence correctly.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DaniWeb

>>Well i have completed my bachelors in IT.
Congratulations :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

IMO the easiest way is to convert both date strings into time_t integers, then just subtract the two integers. That will give you the difference in seconds. After that its just dividing up the seconds into minutes, hours, and days.

The instructions say nothing about calculating the number of years between two dates. so leap years are not relevant to the problem.

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

time_t tokenizedate(const char* datestr)
{
    struct tm tm;
    memset(&tm,0,sizeof(struct tm));
    tm.tm_mday = ((datestr[0] - '0') * 10) + (datestr[1] - '0');
    tm.tm_mon = ((datestr[2] - '0') * 10) + (datestr[3] - '0') - 1;
    tm.tm_year = atoi(&datestr[4]) - 1900;
    return mktime(&tm);
}

int main()
{
    time_t t1, t2;
    char date1[40], date2[40];
    time_t seconds = 0, minutes = 0, hours = 0, days = 0, months = 0;
    printf("Enter first date (DDMMYYYY format)\n");
    fgets(date1, sizeof(date1), stdin);
    printf("Enter second date (DDMMYYYY format)\n");
    fgets(date2, sizeof(date2), stdin);
    t1 = tokenizedate(date1);
    t2 = tokenizedate(date2);
    seconds = t2 - t1;
    minutes = seconds / 60;
    hours = seconds /(60 * 60);
    days = seconds / (60 * 60 * 24);


}
jephthah commented: mo better +11
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Interesting. So are you saying we need to open a bar to promote our web site :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what code are you talking about?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you could use standard C function qsort(), c++ std::sort(), or write your own sort algorithm.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

They add unnecessary complexity?

And, with your otherwise excellent solution, you have to terminate input with Ctrl+Z instead of just <Enter>

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

change "%f.2" to "%.2f"

[edit]what ^^ said too :) [/edit]

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you could use stringstream class in <sstream>

string sentence = "Now is the time for all old folks to be in bed";
string word;
stringstream str(sentence);
while( str >> word)
   cout << word << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you don't need a loop or switch statement. use string's substr() method to extract the first two characters and again to get the last two characters.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is [B]isdigit[/B] a macro then?
According to this information it isn't :P

Its probably implementation dependent. You have to check your compiler's ctype.h header file to find out whether its implemented as a macro or a function. The link you posted doesn't say one way or the other.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think it doesn't know what string is, and I don't think you can pass string objects as parameters to COM functions. Change string to char* and see if that fixes the problem.

>>What does "in" mean in your function by the way?
In COM programming there are in parameters, meaning input and out parameters, meaning output. They are used only in MDL files, not actual header or *.cpp files.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

do you want ms-windows or *nix? Sample code for both are here.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Attempting to compare a single character with a string. Here is how to fix it -- use single quotes instead of double quotes array[i][0] == ' '

Salem commented: You should have suggested " "[0] ;) +35
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

open first input file A
open output file
read input file A (probably use fgets() )
write to output file (using fprintf() or fputs() )
close input file A
open input file B
repeat the above for B
close both files and you are done :)

You need to study your textbook about the functions fopen(), fgets(), fprintf(), fputs(), and fclose(). You also need to know about character arrays that hold the information in memory that the fgets() function uses.

tux4life commented: Professor AD is teaching :P +9
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can use the macro isdigit() to find out if it is '0' to '9'. And the At() method is unnecessary. if( isdigit(word[i]) )

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There is no such concept as HttpSession in c++.

When you logon in java I presume the java code checks a database, such as MySQL, for login credentials. If username and password are verifyed then the user is allowed to continue using the program. C++ programs can do the same thing, but its a little more difficult. There are a couple of ways to access sql databases such as MySQL from C++, one of them is ODBC. If you google for ODBC C++ CLASSES you will find some free c++ classes and some not-so-free classes/libraries.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

. "rt" isn't portable.

Whatever gave you that idea? True, text mode is the default, but there is nothing wrong with specifying 't' in the mode string. If there was then it would be in the c standards.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I just hope I could key in the same number of characters from keyword in 30 sec.At least that would help me to code in hell lot of code in minutes ;)

And with a lot more bugs to fix :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I almost flagged this thread as spam due to the enormous amount of iPod spam posted on daniweb lately :)

And I was about to delete it :)