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

That button doesn't work in New Articles. It's supposed to take me to the first unread post in the thread, but it doesn't.

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

I was only responding to this statement

It's no longer a word used to technically describe Down syndrome, more so as it is used to describe imbeciles and morons, which means it's perfect for 99.9% of Xbox Live users

With the above statement you called everyone who plays an Xbox (probably most people under age of 25) an imbecile and a moron.

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

Only people who have never served in the military would be shocked at the banning. Such a thing is actually pretty common. I recall one time the Base Commander banned a Cheek and Chong movie because it involved drugs.

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

No, are you?

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

>>Course the military should realize by making such a fuss over this game it is just going to guarantee it will be a success
It does seem to work that way with anything that is banned whether it is drugs, alcohol, movies, books, games, guns, etc. I don't know about other countries but in USA banning something seems to produce a backlash affect.

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

It's not necessary to store all the even numbers. All you have to do is add the value of the loop counter to the sum accululator if the loop counter is even.

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

>>It is really hard to learn alone only from books

Many of us learned that way too. Here at DaniWeb you are not alone.

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

Compare the program I posted with what You posted. You failed to add { and } round that while statement, and the comparison on line 10 is still wrong.

You need to learn to pay more attention to the logic of your programs.

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

The formatting leaves something to be desired.
Variable numar needs to be initialized to some value greaterthan 0
The program is missing { and } around that multi-line while statement
The if and assignment statements are backwards

int main ()
{
    int numar = 1, biggest =0;
    cout<<"insert an integer ";
    while( numar > 0)
    {
        cin>>numar;
        if(biggest < numar)
        {
            biggest = numar;
        }
    }
    cout<<biggest;
    system("pause");
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is is a console or gui program? How are you displaying the number?

If you are displaying floats then use fixed

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

int main()
{
   float x = 1000000000000000.0F;
    cout << x << '\n';
    cout << fixed << x << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, and that function can also be used in MFC programs.

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

delete line 10

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

>>I would like to use this tasklist for a cli interface and then change it to a GUI

AFAIK CLR is only supported by c++, not C. So you might as well switch to c++ now if your intent is to use it in a c++/clr project.

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

Ditch that tutorial you are reading and try this one. Its been around for many years and has been used by hundreds of people. You need a basic knowledge of C language -- if you don't have it then you might be in trouble. The turotial comes with complete source code that you can download, compile, and run.

tux4life commented: :) +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm not surprised. All you posted is a bunch of meaningless lines of code. Try writing a real program with functions etc.

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

check the file size then allocate a buffer of that size

char* buf = 0;
ifstream in("filename.bmp", ios::binary);
in.seekg(0,ios::end); // go to end of file
unsigned int size = in.tellg(); // get file size
buf = new char[size]; // allocate memory
in.seekg(0,ios::begin); // back to beginning of file
in.read(buf, size); // read the file
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

it doesn't work because you have to use sprintf() to format the string.

char command[255] = {0};
sprintf(command,"copy %s.jpg \\%s\\%s.jpg" , a, a, a);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I didn't say it was a compiler error. Compilers rarely make errors. I said learn to use your compiler's debugger to find the problem in your code.

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

instead of "0x" for hex use use "0o" for octal, which is consistant with "%0o" in the printf() format specifier.

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

what compiler are you using? Most modern compilers have debugging facilities that let you execute the program one line at a time and view the current value of variables.

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

Oh so now you insult 99.9% of today's young people :) I see you are becoming very popular here at DaniWeb where most members are below the age of 25.

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

Since you are using MFC then call SetTimer() The last parameter is the name of the function you want it to call. See the example in the link.

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

Read about the format specifiers! The 2 in %2d says to display the integer in 2 or more characters. For example if x = 1, then it will show a space before the 1, like in " 1". But if x = 123 then it will just show all the difits, such as "123".

If you want the number left-justified in the field then use "%-2d". In that case it will display "1 ", with the space on the right instead of the left.

If you want 0 filled to the left, then use "%02d", and when x = 1 it will display it as "01" instead of " 1".

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

.bmp files are binary files, not ascii text files. You have to open the file with ios::binary flag and then use ifstream's read() method to read the binary data. getline() will not work. And you will have to read the file into a character array, not a std::string object

char readbuf[255];
ifsteam in("filename.bmp", ios::binary);
if( in.is_open() )
{
   while( in.read(readbuf, sizeof(readbuf)) )
   {
       int bytesRead = in.gcount(); // get number of bytes read
       // blabla
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ODBC is the way to go if you want a program to be able to connect to a variety of SQL-compliant databases, such as Access, MySQL, Oracle, Sybase, etc. etc. See the links that Narue posted. But if you have a specific database in mind then you might get better and faster results by using database-specific API, such as Microsoft's ADO or MySQL API.

You will have a lot more options if you moved to c++, such as MySQL++ for MySQL database.

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

With the loop counter declared as unsigned short what will your program do if n_elements is 0? I would think that declaring the loop counter as int would be a lot safer. If n_elements is an unsigned int then you might want to typecast it to int in order to remove warnings about comparing signed and unsigned int.

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

You don't call DoDataExchange() directly. To cause that function to be called you have to call UpdateData() then MFC will call DoDataExchange(), which will transfer the data from the windows control to your variables, assuming you gave variable names to the controls. If you didn't do that then UpdateData() will do nothing. In that case you have to do it manually, which can be a big pain, but not impossible.

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

You might find something useful here

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

As a retired 23 year veteran I have to agree that the game should be banned from every store in the USA. The game is an insult to every American who died in wartime. If I see a copy of it I'm afraid I will have to burn it in front of the store that sells it.

>>The U.S. military is overstepping its bounds here drastically, something it tends to do best.

Bullshit. The military has every right to ban anything they want from military installations. Military installations and the people on it are not bound by the United States Constitution -- they are only subject to the Uniform Code of Military Justice. US Constitution rights do not apply there. Anyone entering a military institution give up those rights during their stay.

Glass_Joe commented: Wholeheartedly disagree +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well, did we answer your question or not? If we did then please mark this thread Solved.

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

Didn't the example I posted help you? It contains one setter and three getters. If that isn't what you are asking then you need to explain yourself better and with example. The example you originally posted is almost identical to what I posted.

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


It does not. After vfork the parent process is blocked until the child does either _exit() or execve. Parent and child never run in parallel while sharing memory space.

I have no clue how vfork() works -- I was just comparing the posted results with how MS-Windows CreateThread() works. The test I posted and ran works just as you described for vfork() -- the win32 api function WaitForSingleObject() causes the thread to wait until the child thread terminates.

The point is that even though parent and child have distinct FILE objects, both of them refer to the same file obect in the kernel. The parent's ftell() obtains the read pointer from this shared object, which is of course affected by child's read().

But if that is the case they why are parent and child file pointers different on some operating systems and the same on others? (Note: I'm not trying to state an opinion here, but just asking a question from someone who is probably more knowledgable about this than I am.)

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

Is it possible to do what? There is no restriction on the number of getters you can put in a class.And you have to put { and } around all functions even if they are only one line. I always make one liners inline code instead of in an implemnentation file

class C3dshape
{
private:
   int mLength;
   int mWidth;
   int mDepth;
public:
   int getlength() {return mLength;}
   int getwidth() {return mWidth;}
   int getdepth() {return mDepth;}
   void setvalues(int Length,int Width, int Depth)
   {
      mLength = Length;
      mDepth = Depth;
      mWidth = Width;
   }
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Assuming you have a pure win32 api program, send WM_GETTEXT message.

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

move the declaration of that vector up outside the do loop. Its contents are being trashed on each iteration of that do loop. You have to declare it outside the loop so that its contents are preserved.

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

Post new code because I can't see what you have done.

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

It only prints the last name that was input because when cin >> name is called cin will erase the current contents if name and replace it with the new keystrokes. If you want to keep all the names in memory then you will have to put them in an array, preferably a std::vector.

std::vector<std::string> namelist;

...
cout << "Enter a name\n";
cin >> name;
namelist.push_back(name);

...
...
// now display all the names that were input
for(int i = 0; i < namelist.size(); i++)
{
   cout << namelist[i] << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Books??? There is an entire thread devoted to that topic. See this link

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

C++ doesn't have native graphics support because it wasn't designed for that purpose. If you want native graphics then use c++/CLR (Windows Forms), C#, or VB.NET. As I said before, use the language that best supports the program design -- C++ is not a language for everything.

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

MS-Windows creates threads just like vfork, where all threads share the same memory. I didn't realize fork() creates new data space :-O

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

Are you writing a console program or win32 api GUI program, or something else, suh as wxWidgets?

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

@Adak: I'm pretty sure you probably know this, but for those who don't: The reason it failed is that Turbo C is a 16-bit compiler and the programs is produces is limited to 640 Meg RAM, mimus the amount needed for the operating system and other drivers. It actually winds up to somewhere between 450-540 meg.

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

>>I managed to read the whole file in one string

No you didn't. fgets() will not read the entire file into a single character array because fgets() stops reading when it encounters the first '\n' -- which is the character that terminates a line. So all your program will do is read the first word in the file.

>>Is there a way too keep this dictionary in a variable in C
Use a linked list of words. AFAIK there is no limit to the number of words that can be store in memory that way, except of course the amount of available RAM and hard drive swap space. Hopefully, you are not foolish enough to use a 16-bit compiler such as Turbo C.

tux4life commented: Good catch :) +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

One of the new features of VC++ 2010 is that it parses the code as you type it, so if you do something wrong it will highlight the error right way for you. You don't even have to comile the code to see many errors.

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

They occur because you screwed up. Look at the error messge then the line that caused the error and try to figure out what caused that error message. Sometimes the real problem is on a previous line (or lack of one).

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

AFAIK there is no such book. Code reviewing just tasks a group of programmers to review each others programs for consistency with company coding standards. There is no right or wrong way to do it -- well, almost none. The coding standards will vary from one company to another, so there is very little consistency among them.

You will find a wide range of standards and guidelines from these google links.

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

Practice. Practice. and more Practice. And study books and tutorials -- tutorials are all over the net, just use google to find them.

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

Never, ever, for any reason, use gets() because it will net you corrupt the entire program. That's why I (and everyone else who has half a brain) use fgets().

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

If the buttons are on a Panel container then you need to set the TabStops property so that the Panel is number0 and the buttens each have a higher and unique number. So if the form contains a Panel and two buttons, then the Panel is TabStop 0, and the two buttons are TabStop 1 and 2, respectively.