Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Form1 ff = gcnew Form1();

it probably want's you to declare 'ff as a 'Form1*', but i could be wrong since i've never seen the 'gcnew' operator before.

Probably Form^ ff , depending on which version of CLR.


>>I'm new to C++,
If you are trying to learn c++ than stay away from CLR and Forms because that is almost another language in itself.

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

Nobody is just going to give you all that code. First you have to decide what the program will do -- design the menus, screen layouts, etc. Write it down on paper so that you don't get confused. Once you are finished with that then you can begin to write the program.

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

It's baaack :) Thank you Dani :)

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

You might write a database program, such as a DVD/CD maintenance using an SQL database such as SqLite. You will have to learn SQL language.

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

programs originally written with turbo c can not be easily ported to other modern compilers due to the differences in the graphics. I suppose you could port all the functions in graphics.h to use win32 api graphics functions, but it might be easier just to rewrite the turbo c program.

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

You don't have the time nor the skills to tackle large games, Here are some links that might help you.

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

Make sure you compile the program(s) for release, not debug. You might also have to install one or more of Microsoft's dlls, they are located in a folder called redist in the compiler's install directory. On my computer they are here: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT

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

What is the words CODE doing in that program? There is no such thing in C or C++. Are you confusing it with the CODE directive in assembly?

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

You can write files anywhere you want to on your computer as long as your login account has permissions to do that. For example newfile.open("c:\\dvlp\\test\\exemplu.txt");

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

>>So what really decides the size of an exe file.
Your compiler. Two different compilers using the same identical code can produce different exe sizes. And the same compiler can produce different exe sizes depending on the flags you give it, such as DEBUG and UNICODE, and the way it might optimize or not optimize the code.

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

>>but does not seem to work...
What doesn't work? Do you get compiler errors? If yes then post the first few errors.

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

>>why not 4 bytes.

You answered your own question in the first sentence you posted. Because 5 * sizeof(int) = 5 * 4 = 20. Simple grade-school math.

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

you first need to learn how to build a windows gui program. Here is a tutorial to get you started.

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

1) iostream.h is obsolete -- use <iostream> instead (without the .h extension. Current c++ standards have removed the .h extension in all its header files.

2) conio.h -- that is a non-standard header file that was originally implemented by Borland compilers such as Turbo C. It was picked up by a few other compilers, but implementations were often not the same. That header file never did become part of the C or C++ standards. You should delete conio.h from your programs unless it contains something you absolutely can not live without. In that case don't complain if other compilers refuse to compile your programs.

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

Post what you can do and ask questions about what you can not do. Also tell us what compiler you are using.

#include <stdio.h>

int main()
{
   // write our program here

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

You both should ditch that compiler and use Code::Blocks with MinGW instead because they are newer and still actively supported. Dev-C++ has not been updated in quite a few years and uses an older version of gcc/g++ compilers.

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

>>I am not so sure whether the C++ iostreams can do all that the Windows API can.

If your compiler supports iostreams for the os, then the answer is yes. For binary data just call iostream's read() and write() methods, which are nearly identical to win32 api ReadFile() and WriteFile() functions. The win32 api functions allow for gigantic huge files, but you don't need to worry about that because you can not create/store files that big on WinCE devices.

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

That's not quite so. Basically system() returns the value from the command interpreter i.e. it can well be used like the OP is planning to use it. MSDN documentation about system()

Like I said -- the return value of the command interpreter is also pretty much useless. The command interpreter does not return the exit status (or exit value) of the program/process that was executed. If your program doesn't need that, then no harm done. Otherwise don't get the false impression that system() returns something that it does not.

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

Hi all

Was anyone able to shed light on my earlier post of how to send 'binary' data to the comm port in Visual Studio (C++)?

Thanks

Already told you in my original post to this thread. All data send through the com port is sent as binary data, even if it is just a text string. The communications functions don't care what you send -- the programs on the sender and receiver side have to know how to interpret the data, not the comm functions.

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

Hi there,
thanks alot for putting up the code, just what I wanted!
however I do have a small problem. what do I type to replace the words 'CODE' in serial.h and serial.cpp? if i just comment them out, the compiler gives error
.\serial_comm2.cpp(103) : error C2664: 'CreateFileW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR', which i think is linked to the fact i commented them out.
really sorry I'm a newbie!

you can reply to my hotmail<EMAIL SNIPPED>
Thanks!

You must be compiling for UNICODE. You can turn that off if you need to. If you don't want to turn UNICODE off then you will have to change the code he posted to use tchar_t (or TCHAR) iinstead of char.

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

Help you do what??

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

why are you doing that the hard way, such as one character at a time, when there are much faster, easier, and less error-prone ways, such as fscanf() . If your instructor requires you to do it that way, then do it. Otherwise you have just wasted how many hours??

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

What a horrible looking mess. Complete and total lack of any programming style.

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

this should be funny
http://www.facebook.com/photo.php?pid=10219262&id=878590034

What is so funny about that??

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

Wer can i know more details about that lint program ????

google

Salem commented: Simple and obvious really :) +17
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I downloaded, installed and created a test console program. Interesting looking C compiler (it is not a c++ compiler too).

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

See CEdit's SetSel method

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

If you want to write your own, you will probably want to study yacc (Yet Another Compiler Compiler)

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

I created a new C console project with Code::Blocks and it did not produce a warning or error on malloc(), just as I had suspected. Then I created a new C++ console project, changed the file extension to *.c and Code::Blocks produced an error like you said. Apparently the compiler doesn't know that *.c is a C source file, not c++. So you obviously created the wrong kind of console project.

nt main()
{
    char *ptr = malloc(25); // no warnings or errors here
    strcpy(ptr, "Hello World");
    printf("%s\n", ptr);
    free(ptr);
    return 0;
}

>>157 I don't understand what you mean, I allocated the memory of c at line 142

No you didn't. line 142 declared a character array ON THE STACK and such arrays can not be used in the return statement. Even if you allocate new memory for c using malloc you still can not return a pointer to somewhere in the middle of that array because the original pointer will be lost and result in a memory leak. The only way to successfully return a character array is the way I mentioned. Well, there is another way but it is a little more complicated -- pass the pointer by reference to that function

const char *getWord(int wordN, char** retvalue) {
...
...
  if( retvalue != NULL)
  {
      // deallocate the pointer if necessary
      free(*retvalue);
     *retvalue = malloc( ... );
     return *retvalue;
  }
}

int main()
{
    char *ptr = NULL;
    
    char* word = getWord(wordN, &ptr) …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>oes the child class have access to those, too then?
No.

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

Its not possible to delete just the parent -- when you delete the child then parent gets deleted too. Both parent and child form a single object, not two.

Excizted commented: Quick, straight as always :D Thanks. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are suggesting a blackball list? Or a hit list? Just because someone doesn't mark the thread solved, reply, or post a thank-you doesn't mean your post was not helpful or unread. Of all the 10 thousand threads I have posted in only 1500 of them were marked solved, or roughly 15%. Are you saying the other 85% should be on my hit list?

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

Why do you want to save the output to a file just to understand return codes? The return code from system() is pretty much useless -- all it indicates is whether system() successfully ran the command or not. It says nothing about the program that system() ran. If you need to return code of the program (not system()) then you need to spawn it in some other manner, such as on MS-Windows use CreateProcess(), WaitForSingleObject(), then GetExitCodeProcess(). Here is a link with sample code.

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

The structure isn't correct, you don't have to specify the number of digits in the integers. A single integer can hold lots of digits (see limits.h in your compiler's header files).

typedef struct
	{
	int site_id_num; /* id number of the site */
	int wind_speed; /* the wind speed in knots */
	int day_of_month; /* the day of the month written as dd */
	int temperature; /* temp in celcius */
	}measured_data_t;

lines 20 and 21: It isn't necessary, nor even desireable, to put those on two different lines -- just declare the function all on one line int main() lines 36-39: you need to make those parameters pointers if you make the changes I suggested to that structure. e.g. & measuredp->site_id_num You also need to make that a loop so that it will read in all the rows in the file. Then store the data in an array of structures.

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

>>invalid conversion from *void to *char
You must be compiling that program as c++, not C (filename has extension *.cpp, not *.c). C does not require typecast, c++ does. Rename your program to have *.c extension and you will not get that error.

>>so I didn't add that part into the code.
Big big mistake. So instead of correcting your program you decided to just leaved the bugs in.

line 157: That return will cause program crash because it is returning a pointer into array c, which will get destroyed as soon as that function returns. You need to allocate new memory and return a pointer to it.

char* p = malloc( strlen(token)+1);
strcpy(p, token);
return p;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

did you try google to find that error message ?

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

How are you trying to scan? I have HP Officejet 6500 and the HP program that worked great on Vista is not yet supported on Win7. So I have to use Windows Fax & Scan program which HP recommends on their support site. Click on the Start icon in the task bar, then type Windows Fax in the Search edit control and Win7 will produce a link to the program.

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

If your target os supports standard iostreams then I'd use it. win32 api is very low level and supports only binary files -- yes text files can be written as binary files but using std::fstream makes it a lot easier.

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

ODBC is the oldest and most common way to access SQL databases with C and C++ languages. google for "odbc tutorials" and you will find some. You will also need to learn the SQL language. Although there is supposed to be a standard sql each database publisher implements its own little quirks. What works with one database may or may not work with others.

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

line 7: >> char getWord(int wordN) {

All getWord() will return is a single character. What you want it to return is an entire string, so declare it like this: char* getWord(int wordN){ I think you want arofstr to be an array of 200 strings. Then declare it like this: char* arofstr[200] = {0}; That is an array of 200 pointers, and each pointer is initialized to NULL.

line 40: you will have to copy the entire string to the pointer -- the = symbol will not do that.

arofstr[f] = malloc(strlen(token)+1); // allocate memory for the string
strcpy(arofstr[f],token);

line 51: You need to free() all the strings except the one that you want to return.

int i;
// free all the memory allocated for the strings
// It is ok to pass a NULL pointer to free(), so you
// don't have to test for that.
for(i  = 0; i < 200; i++)
{
    if( i != wordN)
         free(arofstr[i]);
}
// now you can return the string
return arofstr[wordN];

line 57: its int main(). Most modern compilers will complain if you declare it anything else.

line 65: >> char guessWord[] = getWord(wordNumber);
You have to use a pointer here: char* guessWord = getWord(wordNumber); or you could copy it

char guessWord[255];
char* ptr = getWord(wordNumber);
strcpy(guessWord,ptr);
// now free up the memory returned by that function\
// to avoid memory leak.
free(ptr);

line 67: >> int wordlength = sizeof(guessWord) - 1;
Can't …

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

IMO phthon is a toy that non-programmer hobbyists use, in the same category as Quick Basic. C/C++ is used by professional programmers to write real professional programs.

Rashakil Fol commented: fail -1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In the while loop you need to change variable i to something else because that while loop is destroying the value of i that the for loop is supposed to increment. Copy the value of i into another variable, such as k and use k in that while loop.

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

Read Microsoft's Scribble tutorial.

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

I've never tinkered with usb so I don't know the answer to your question. The ones I have used were connected to COM port.

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

Get row: you will have to sequentially read each line of the file in order to get to the row you want.

Delete row: rewrite the entire file, omitting the row to be deleted. Open two files: input file is the file that contains the row to be deleted, the second is an output file that will contain the new rows.

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

Depends on how the card reader is attached to the computer. If its attached to a COM port then use MS-Windows communications functions.

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

>>Here's a question for you.
Not for me -- I already know how to do that.

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

I started learning MFC with the Microsoft Scribble tutorial. Like any other tutorial it only scratches the surface of MFC. It has been said there is about a year's learning curve to learn MFC well. You should also get acquanted with www.CodeProject.com because it has hundreds of free MFC stuff, including tutorials and example programs. Its one of the best (maybe the absolute best) source of MFC code on the net.

You might also want to invest a few $$$ in one or two good books -- search amazon.com for "mfc computer programming" and it will show you several good books you can buy.

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

If you want c++ then look at MFC (not free) or wxWindows or QT (both are free). MFC will require you to BUY VC++ 2008 or VC++ 2010 Standard or better editions (free Express does not support MFC). wxWindows can be used with most 32-bit compilers. QT is a compiler all its own.

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

>>I've been searching for this on Google for about two weeks now and keep coming up dry

You mean you have been googling for two weeks and never tried this? :icon_eek: Read the first link you see.