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

In C language the fgets() function will trim leading and trailing spaces from words read. It will also skip over '\n'. Text files do not contain '\0' bytes; if your file does then it is not a text file.

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

>>but I'm worried about the side effects of doing it like this. Such as unexpected termination leaving the connection open....

That isn't a problem because the connection will close then the application closes. A much more real problem is what happens if the connection accidentally closes while the program is running.

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

Does it give you any kind of runtime error message, such as "dll can not be found" or something like that?

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

Read this -- send WM_ENABLE message to the button.

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

How do I convert each indviudal value of my file so that I can specify it either as int, float, or string?

Simple substitution -- call find() to locate the comma and replace it with a period.

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

Try this: both first and last parameters can be NULL.

URLDownloadToFile(NULL, "www.DaniWeb.com/something.jpg",
     "c:\\mydir\\something.jpg", NULL);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>so it just bogs the shit out of the game..... anyone have any ideas on this?
Yes I know. Database access is always slow. Maybe you need to shove the database access code in another thread so that it doesn't affect the game. And your problem will only get worse as more people try to play the game at the same time. MSAccess is not a very good database when more than a couple people try to use it at the same time. If you want more people when swap Access out for something like MySQL.

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

An environment of freedom would not include massive bail-outs and government buy-ups of an arbitrary list of companies -- using other people's money, of course.

I agree, but that is socialism, not capitalism. We (USA) are apparently in the process of becoming an even bigger socialist country then we already are. Only time till tell if our government eventually re-privatizes the companies it is now buying. The government bought 62% of GMC and has said it will eventually sell those shares -- I won't hold my breath for that day.

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

The new c++ standards, which will not be released for some time yet, is supposed to allow arrays to be allocated like that: int ay[size] where size is not a const integer. A few compilers may already support it, but if they do it is compiler-specifc.

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

A simple example

#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main()
{
std::vector< std::string > theList;
std::string str = "Hello World";
size_t pos = str.find(' ');
theList.push_back( str.substr(0, pos) );
theList.push_back(str.substr(pos+1));

// now display the two string
for(size_t i = 0; i < theList.size(); i++)
    cout << theList[i] << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Look in the directory in which the project is store -- the name of the header file is most likely Form1.h.

>>Also i want to access its controls for updating.
Don't know.

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

I don't know a thing about Chinese characters, but I would suggest reading the file 2 bytes at a time. After reading 2 bytes test to see if it is a valid Chinese character. If not, assume its two ascii characters. Then write out either the chinese characters (which are already in UNICODE format), or convert the two ascii characters to UNICODE format and write them out. Converting from ascii to unicode is quite simple

wchar_t  c; // unicode char
char ascii = 'A';
c = (wchar_t)ascii;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Serkan: your whole problem is that you need to get yourself a nice woman to satisfy your lustful desires. One who can relate to you both body and mind, not someone just in virtual computerland. Get married, have a few kids. But stop that kickboxing, it ain't healthy for you :)

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

Worked ok for me. Post the code you tried and a few of the compiler errors.

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

I think what you want is an ftp library -- here are some links.

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

You mean you want help on how to keep your team members happy and still be able to develop the DLL?

>>do you define an interface, then write the implementation to a DLL, then pass the DLL around, then.
Basically, yes that's the way to do it. But it doesn't mean that DLLs can not be changed once it has been passed around. The programmer who is responsible for developing the DLL should do it on his/her own computer until its ready for release to other team members. The fundamental DLL interfaces should now change from one release to another so that other team members do not have to rewrite their code, unless you want a mutiny on your hands.

If there are lots of project changes during working hours then schedule nightly command-line builds so that all team members have updated programs, libraries, and DLLs the next duty day.

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

>> string s = "data.txt"; // an example
Delete that line

xiikryssiix commented: thank you for your repetitive help! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why do you need to write a new function for that? Just subtract the two pointers as shown in the code I posted. By "count the distance" probably means count the number of characters. Subtracting the two pointers returned by strtok() will do that.

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

just put the strings in a vector: vector<string> ay; >>Oh and just for curiosity, in what manner does strtok modifies the string?
It replaces the separator token (such as a space or a comma) with '\0' then returns a pointer to the beginning of that segment of the character array. Therefore you can not pass it a string literal.

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

Looks ok to me. The only problem I see is that >> operator will not allow the file name to contain spaces. You need to use getlin() if you want spaces.

Why do you think the code you posted does not work?

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

std::string's find() method then use std::string's substr() method to extract the string. IMO its better than strtok() because it doesn't modify the original string.

If you were using c++/CLR then it's String class has a Split() method, but that isn't standard c++ and works only with Microsoft compilers.

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

Here is a vector tutorial that might help you. They are not all that difficult -- the code I posted is about as basic as one could get.

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

m_pointVar has to be a pointer for that to work. If it isn't, then how to check will depend on the class. Make the class constructor initialize all its variables and the program user won't have to worry about whether it was initialized or not.

Testing for NULL pointer will not even tell you whether the pointer is valid or not. It might be an uninitialized pointer or a pointer that was deleted.

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

Here is another way to do it since the requirement is to use <vector> class.

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

int main()
{
   vector<float> ay;
   for(float i = 0.0F; i < 1.0F; i += 0.1F)
       ay.push_back(i);

   vector<float>::iterator it = ay.begin();
   for( ; it != ay.end(); it++)
   {
       cout << left << setw(10) << setfill('0') << *it << "\n";
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Post the code you tried to write.

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

That worked, thanks.
But can someone explain why do i have to declare it as a pointer?

You had to declare it as a pointer because on line 13 you used the new operator to allocate memory for it. If you delete line 13 then you don't need a pointer.

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

>>ChatSession cs;

cs must be a pointer -- ChatSession* cs;

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

You could, of course, roll your own function that provides that feature of unlimited buffer length

#include <stdlib.h>
#include <string.h>
#pragma warning(disable: 4996)

#define TRUE 1
#define FALSE 0

int getline(char** buf, FILE* fp)
{
    const int BLOCKSIZE = 10;
    int c;
    int size = 0;
    int maxsize = 0;
    if( *buf != NULL)
    {
        free(*buf);
        *buf = NULL;
    }

    maxsize = BLOCKSIZE;
    *buf = realloc(*buf, maxsize);
    memset(*buf, 0, BLOCKSIZE);
    do
    {
        c = fgetc(fp);
        if( c != EOF)
        {
            // check of we need to allocate more memory
            if( size == (maxsize-1) )
            {
                maxsize += BLOCKSIZE;
                *buf = realloc(*buf, maxsize);
            }
            (*buf)[size] = c;
            ++size;
        }
    }while( c != '\n' && c != EOF);
   (*buf)[size] = 0; // null terminate the string
   return  (c == EOF) ? FALSE : TRUE;


}

int main()
{
    char* buf = 0;
    FILE* fp = fopen("test2.c", "r");
    while( getline(&buf, fp) )
        fputs(buf, stdout);
    fclose(fp);
    free(buf);

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
int distance = 0;
char str[] = "Hello World";
char *ptr = strstr("World");
if( ptr != NULL)
   distance = ptr - str;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you just admit to using vista? JK,

Nope :) Everyone already knows it.

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

On my Vista computer that dll is in c:\windows directory. You might check your computer to see if its already installed. Also read this article.

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

>>cs = new ChatSession(*t2);

The error message is telling you that *t2 is just a single character, not a character array. Maybe you mean this? cs = new ChatSession(t2);

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

That program still has warning about uninitialized variables being used. Fix them because the program will have erratic behavior the way it is.

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

This is something similar to what you want -- not exactly but in the ballpark. The button image changes when you hover the mouse over it, so you should be able to change the behavior to make the image stay in place after clicking it.

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

you could probably create the Form1.cpp yourself and put implementation code there just like you would do with standard C and C++ programs.

[edit]Just tested it, and yes you can do that just like normal c++ programs.
[/icode]

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

You forgot to tell us what the problem is that that code.

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

Maybe you should use a check button. Or search these links for something similar to what you are looking for. codeproject.com has a wealth of MFC and other code.

Creator07 commented: You are always the best +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The only problem with your program is that you need to set local for the stringstream object.

while (getline(infile, line))
	{
        stringstream strstr(line);
        string word = "";
	    strstr.imbue(locale("german_germany.1252"));
        while (getline(strstr,word, ';')) 
            all_words.push_back(word);
    }

Attached is the output file I got.

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

If you are looking for code that fails, this doesn't work either. for(int x = 1.0; x != 0; x -= 0.1) There are lots of ways to make floats fail due to rounding errors. For example x = 1; x = x / 3; You think the result would be 1/3 right? Wong. Its 0.33333333333 ...

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

Instead of reading the file one character at a time, why not use getline() to read the entire line?

while( ls.getline( temp_isi_file, sizeof(temp_isi_file), ',') )
{
     // now temp_isi_file only contains one integer
     int n = atoi(temp_isi_file);

    // or if you prefer c++
    stringstream str(temp_isi_file);
    int n;
    str >> n;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Look here -- should be hundreds of ideas

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

google around and you will find them. For example, read this article, which gives several installation programs.

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

>>First time I compiled it with MicrosoftC++ and gave me just 1 error, that corrected
You should have tried to compile it again with that compiler. I used VC++ 2008 Express and the code you posted had billions of error messages.


There are indeed several errors.

1) struct art -- you should make that a class, not a struct. Yes they are nearly the same thing but its customary to call it a class when it has methods. Same with struct venta.

2) you forgot the semicolon at the end of struct venta

Lots of other problems that you need to fix.

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

In think you are talking about an installation program such as InstallShield, or possibly a compression program such as WinZip and PkZip (but they will not run a program after the files are copied),

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

>>Yes, people can go around doing what they dam well please. As long as it doesn't infringe in the freedom of any other

The rapist comment was meant to be a bit extreme, and of course I quite agree with you. your freedom stops where my nose begins. And that was the whole point of my comment.

And I also agree that a lot of the problems politicians try to solve either do absolutely nothing or just make it worse. Take the Great Society of LBJ. After 50 years it has done virtually nothing except create generation after generation of people addicted to social welfare programs. And the War On Drugs is also a disaster.

But that doesn't mean that Capitalism itself is bound to fail. Capitalism is an economic and social system, not a political one. The USA is not even a Democracy -- its a Federal system. Therefore the USA is a Federal political system which operates in a socialistic/capitalistic society. We are neither pure capitalist nor a pure socialist, but some combination of the two.

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

Already gave you a couple suggestions here

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

>>kindly check if it is having an error..
Don't you have a compiler that you can check it yourself?

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

Just simply use the macros

#include <iostream>
#include <windows.h>
using namespace std;

int main()
{
    DWORD dwWord = 1234567890;
    long lWord = LOWORD(dwWord);
    cout << lWord << "\n";
    cin.get();
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Start out by reading the Read Me threads at the top of the c++ forum. Especially the FAQ and Books threads.

Then google for c++ tutorials. Best to buy and study books, but if you can't afford them then read tutorials.

>>And my dream is to take over the operating system industry and make every people like my operating system!
LOL. So you want to put Bill Gates out of business???

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

>>The only system that is sustainable is one where individuals run their own lives.

Well, that's not entirely true. People can't just go around doing anything they dam well please. I can't go out and rape every woman I see on the street. There has to be some limits on human activity.

>>it is because they will personally benefit by better decisions that they have incentives to improve their decisions.
Theoritically yes. but that doesn't work in the real world. Drug problems are getting worse in this country (USA), not better.