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

I think you mean:

#include <iostream>
#include <fstream>
 
using std::cin;
using std::cout;
using std::iostream;
using std::ifstream;
 
int main()
{
 
   // your program goes here
 
}

Huh??? Isn't that the same thing I posted??? Both are incorrect. std::iostream should have been std::ofstream;

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

That was quite an accomplishment for a 13 year-old in 1968.

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

>>I'm using Visual Studio 2008 and referencing a book called "MFC Programming with Visual C++ 6"


Get a newer book because MFC changed a lot between VC++ 6.0 and VC++ 2008. The two are not compatible, although you could make it work if you already know MFC well enough. Since you are just starting it would be a lot easier if you just bought a newer book.

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

In addition to what ^^ said you can't just send a byte out the serial port. The port has to be set up first with stop bits, data bits, parity and baud rate and those must match whatever is on the other end of the serial port.

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

Start with this:

#include <iostream>
#include <fstream>

using std::cin;
using std::cout;
using std::iostream;
using stdLLifstream;

int main()
{

   // your program goes here

}

Next you will have to create a list of questions and their four possible answers, save them in a text file or just hard code them in your program.

Select one of the questions at random, display the question and four possible answers. Then ask the user to enter a,b, c or d (one of the 4 possible answers). Repeat as often as necessary so that the user can win a million dollars.

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

Remember that Bill gates was virtually a minor when he developed windows...;)

Bill Gates, born in 1955, was about 30 when the first version of Windows was released in 1985.

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

That can not be returned from a dll because memory allocated in a dll can only be destroyed in the DLL, and memory allocated in an application program can only be destroyed in the application program. The two are not compatible. A better way to do it is to add another parameter that is a pointer to the data that is being retrieved, which will be allocated by the calling function, not getData()

It would be the calling functions responsibility to typecast returnData into what ever data type it expects. And that might be difficult if it doesn't know what data type is returned.

extern "C" __declspec(dllexport) BOOL getValue(const char *valueName, void* returnData, size_t returnDataSize)
{
    return RegGetValueA(hKey, lpSubKey, valueName, RRF_RT_ANY, Type, returnData, returnDataSize);
   
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't have to read it all at one time, but you do have to read all of it. Use a loop to read unwanted fields and just toss them out

char buf[255];
// read first 10 fields
int i;
for(i = 0; i < 10; i++)
   fscanf(fp, "%s,",buf);  // something like this
// now read the times.  After that, 
// call fgets() to read the remainder of the line
//

Another way to do it is to read the entire line with fgets() then use strtok() to split it into its individual fields, ignoring unwanted fields at the beginning of the line.

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

The answer is no because variable names can not start with a numeric digit. But in c++ you could create a <map> between a digit and something else such as an integer counter.

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

You could just use a simple while loop.

while(true)
{
   cout << "Enter a positive integer between 0 and 1000: \n";
   // rest of code goes here
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>a new array that needs to allocated dynamically

Your program has not done that. And the loop on lines 15 - 19 is useless, just delete it.

First, call new to allocate an array of the same number of integers as the original array.

Next, use a for loop that counts from N (where N is the number of elements) to 0 and copy the data from the original array to the new array. Do not -- repeat DO NOT, change the value of nums variable because it must remain the same as it was after the call to new. Instead, just index into it, such as nums[i] = array1[j];

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

There is no upgrade to that compiler -- it has been dead and buried for quite some time now.

I think using mangled names is common to all linkers -- all Microsoft compilers do that too. It's beyond the scope of a linker to know the unmangled name. The mangled name is actually more useful information because it tells you exactly which of all function overloads caused the problem.

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

This is a C program, not C++, so Narue's thread will not work.

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

You need two nested loops, not just one. The first loop counts from 0 to num then the inner loop counts from 0 to the value of the outer loop, something like this

for(int i = 0; i < num; i++)
{
    for( int j = 0; j <= i; j++)
    {

    }
}
theoryforlife commented: Great for explaining why to include the function +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

if you enter 0 or 1 for the three sensors frontPad, rearPad, and door,
it shows the first or two results then it terminates
how could I keep it going where when I enter the input, it won't terminate?

thnx

Put the code in a loop.

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

Will you please make up your mind about the file format. The code I posted works with the format you original posted. You can easily enhance the program to suit whatever format is the file by changing the fscanf() line to accommodate more parameters. Its not possible to read just the time that's in the middle of the line -- read evrything on the line.

And, please spell English words -- its "then" not "den". You sound like a 2-year-old when you write like that.

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

line 18 is wrong -- the array does not have 6 elements, only 5, which are numbered 0,1,2,3 and 4. There is no 5th element.

The parameters to the function in lines 5 and 27 to not agree.

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

>>please check this code :

1. its int main() never void main()

2. What exactly do you want us to check?

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

You mean like this?

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

int main()
{
    int hour,minute,second;
    char ampm[4];
    FILE* fp = fopen("TextFile1.txt","r");
    if( fp == NULL)
    {
        printf("Failed to open file\n");
        return 1;
    }
    while( fscanf(fp,"%d,%d,%d,%s\n", &hour,&minute,&second,ampm) > 0)
    {
        minute = (int)(((float)minute/60.0) * 100);
        printf("%d.%d\n", hour,minute);

    }
    getchar();

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

That zip file can not be opened by WinZip.

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

When you create a DLL project the IDE cretes two *.cpp files, not one. DllMain() is generated in dllmain.cpp.

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

You have to capture mouse events, which will give you the x and y coordinates of the mouse. Then just test those coordinates against the area of the window you are interested in to see if the mouse clicked inside or outside the rectangle.

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

One way to do it is to put all the code to read and write a file in a function, then call that function twice from main() with the name of the input file eacj time, something like below except you should use a different name for the function.

void foo(const char* inputfilename, const char* outputfilename)
{

}

int main()
{
   foo("data01.dat", "out1.dat");
   foo("data02.dat", "out2.dat");
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>//#define CreateFile CreateFileW; // I added this line, for solved this error: error C2664: 'CreateFileW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'


DON'T DO THAT! CreateFile is declared in windows.h. Fix the error instead of trying to code around it. If you want to use char* then don't compile your program for UNICODE. To do that select Project --> Project Options (bottom of the menu list) --> Configuration Properties --> General. Then on the right side of the screen change Character Set dropdown to Not Set.

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

>>fd=open("abc.c");

That file is neither object file or executable file. Its a C script file. On MS-Windows you can easily tell the difference between object and executable by its file extension. On *nix executable files do not normally have extensions, but you can identify them by the file permissions mask. And with that you would not know the difference between a compiled executable program or a shell script, which is just a text file.

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

>>now i need to divide column of min by 60

Why? Does the minute column ever exceed 60? If not then there is no point doing that division.

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

Entry level programmers are not expected to be as competent as those with a year or more experience. Just show your prospective employers that you know the basics and you will be oki. As for the number of languages, just concentrate on one or two so that you can gain expert knowledge of them. You don't want to be "Jack of All Trades, Master of None.". But you have to fullfill your school's requirements. I would say C and/or C++, Java and SQL would be good start. If you have time you should branch out into web scripting too.

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

You can tell if you are trying to compile a C or C++ program by the file extension. *.c compiles as C code, while *.cpp compiles as C++ code.

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

In the while statement you posted the value of num was never changed, so all you had was an infinite loop, except for the break statement you had on line 32. The break statement cause the while loop to terminate after the first iteration.

for loops are ideal when you have to increment a counter until it reaches a specific value, such as in the project you are now working on. while loops, although they can be made to work too, are not quite as convenient as for loops.

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

I heard that same argument 25 years ago. Yet there are still a lot of people and companies who need programming work but either don't want to do it themselves or don't have the time. freelance jobs are secure in the forseeable future.

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

ON line 19 try a for statement instead of a while statement. for(num = low; num <= high; num++) And delete the break on line 32.

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

>>is there a way to decompile windows xp without any programming experience or experteese

That's like asking "is there any way to build a skyscraper with no prior construction or building experience?". The simple answer, of course, is "Yes there is -- hire someone who knows that he/she is doing." I'm not saying you can get C or C++ code from disassembly, only that dissembly is possible.

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

Are all the operating systems in the whole world which are connected to the internet going to have to be changed in order to implement IPv6? Or will the first 128 bit address going to break the entire internet?

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

move line 33 up to just above the } on line 31.

line 13: should use variable low here, not num.

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

line 90 us wrong because function Accelerate() returns void, which means it can not be used in a cout statement.

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

Attached is an exmaple project that has two forms

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

Post the code you have tried. If you don't know where to start, then start here

#include <iostream>

using std::cin;
using std::cout;

int main()
{
   // code goes here
}

Write the program just a little bit at a time and you won't get overwhelmed about the program's complexity.

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

what do you mean by "it won't work"? You need to be more specific. Do you take your car to auto repairman and simply tell him "my car is broke, fix it please."? Of course not, you have to tell him what you thnk is wrong and what the symptems are.

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

line 27 is wrong. Take a good look at it and you will see what's wrong with it.

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

Sounds like he is using a MAC.

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

You need to understand how the IDE works -- the project contains both a.cpp and b.cpp. The IDE calls the compiler for each of those *.cpp files, then links them together with other libraries to generate the *.exe file. That's one reason you should never include one *.cpp file in another.

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

Your compiler did not lie to you -- variable low is being used before it as initialized with a value. At that time the variable contains just some random value, whatever was left in the memory location. How to you fix that? Just initialize it when it is declared, e.g. int low = 0;

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

lines 1 and 10 -- you must use a pointer there, e.g. void Password(char* password) Since the character array is declared inside the Password() function, the function needs no parameters. Just void Password() Then in main() all you have to do is call it

int main()
{
    Password();
}

lines 19 and 27: you can not compare a character array with a string literal using = operator. you have to call strcmp() to do that. if( strcmp(password,"test") == 0) line 20: never ever call main() for any reason. That function should only be called from the operating system. That line should only be a simple return statement. return;

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

My guess is that you have a project that contains both a.cpp and b.cpp, then you have included a.cpp in b.cpp. You can't do that. In b.cpp remove the line that includes a.cpp.

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

This is not c++ -- it is CLR/C++ which is another language that was derived from c++. And yes, it is very easy to add the console code to the CLR project -- call the code in the button or menu event handler. The console code won't be able to use cout or cin because there is no console window, but otherwise all other code should work ok.

As for your first question, you have to create another form, say Form2, then display that form in the menu event handler.

private: System::Void availabilityToolStripMenuItem1_Click(System::Object^  sender, System::EventArgs^  e) {			 

     Form2^ f2 = gcnew Form2;   // allocate memory for Form2
     this->Hide();      // hide Form1
     f2->ShowDialog();  // run Form2
     this->Show();      // after Form2 finishes, show Form1 again

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

Here are some hints how to recognize the kind of executable files, but that isn't completly reliable on iteself. Just because the first two bytes of a file contain a certain signature doesn't mean it is an executable file -- it could be a plain text file or some other kind of binary file.

you will have to learn a great deal about the format of executable and object files in order to accurately detect which format a given file is in. I have no idea how to do it and I'm not really interested enough to learn.

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

Looks solved to me :) Maybe you just need to refresh your browser.

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

zlib with source code

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

One purpose I use pointers to pointers is so that other functions can allocate memory for a pointer declared in another function. This is especially useful in building linked lists, which you will eventually discover during your studies.

void foo(char** pointer)
{
   *pointer = new char[255];
}

int main()
{
   char* p = NULL;
   foo(&p);
}