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

study these google links about ODBC. There are other ways depending on which SQL server you are using but ODBC is the most portable and is supported by most, if not all, SQL servers today. ODBC, as well as other methods, are somewhat complicated and accessing in c++ is a lot easier because you can get free c++ classes on the net that do most of the work.

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

how do i build a graphical user interface in visual c++

Its pretty complicated and requires a thorough understandanding of C or C++ language -- definitely not for beginners. But here is a popular tutorial that gives you the basics. How to build the program depends on which oversion of the compiler you have.

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

in the command prompt window type the name of the program you want to run and press <Enter> key. You may have to change directories to where the program is located if it is not in the PATH list.

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

worked for me with Dev-C++ compiler.

#define _WIN32_IE 0x600
#include <windows.h>
#include <commctrl.h>
// rest of the program here
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you attempting to write a C or C++ program? This is the C++ board. If you really mean a C program then I or one of the other mods will move it the the C board.

Excactly how to read the CSV file depends on what character is used as field separator. Normall is a comma, but can also be space or tab.

In a C program, I would use fgets() to get the entire line, then strtok() to split it up into its individual fields.

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

The way I did it was subclass CEdit then enable the OnPreTranslate() function. In that function you can check if the key is the <Enter>, and if it is just return (I think TRUE) so that it gets ignored. I don't have a compiler with MFC to verify, but should be close.

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

>>WIN32_IE

Version of Internet Explorer -- has little, or nothing, to do with the version of MS-Windows except that it must support IE3 or newer. If that section of code is getting skipped by your compiler's preprocessor then define _WIN32_IE to be at least 0x300 to 0x700 (version 3 to version 7).

>>_WIN32_WINNT
That is the minimum version of MS-Windows that your program should support.

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

since there is no such thing as concantenating two numbers, the only option left is strings. But I didn't ask the original question so maybe he has something else in mind :)

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

Hello Friends,
I have got a program for Checking the number that is it Armstrong or not. and to genrate a list of armstrong no. below 1000. The program is in C++.

Great work! So you copied it from here then ported it to c++?

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

If you're on Windows, you could use the windows character map. Make sure that you select the font which matches that of your output window.

that is useless for this purpose because it does not show the hex and octal values for each ascii character.

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

. All the males do is eat sleep and have sex really.

Like most human men :)

iamthwee commented: lucky bastard +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use CFile class in combination with CArchive. But for normal c++ file i/o stuff the ofstream class is a lot easier to use.

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

The old Turbo C is not ANSI standard

True, but that is not relevant to the problem.

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

>>iostream.h

that is for c++, not c. All the other headers are in <install directory>\include folder. In the IDE look at Options --> Directories and make sure it has the correct path.

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

google for ASCII Chart -- there are millions of them on the net. Then in C++ code \xHH is hex code, like this

cout << "Hello my name is \x4d\x65" << endl;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 2: unless you are using a very old compiler such as the original Turbo c++ you should be using header files without the .h extension because there have been some changes.

You should have named your derived string something other than String.h because that is already the name of standard C string functions. Its not good to duplicate file names like that because it will eventually become confusing.

My guess about your specific problem is that you did not include one or more required libraries in the project. Did you include the implementation code for your derived class ?

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

do you mean concatenate two strings? First make sure the destination buffer is large enough to hold both strings. Next make sure the destination string is not a string literal because string literals can't be changed. Call strlen() to find the end of the destination string. Then create a for loop to add each character in the source string to the end of the destination string. Finally null-terminate the destination string by appending 0 character to it.

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

Boy! you really love to use malloc() liberally don't you, even when its more efficient not to. For example:

#define RADARNAMESIZE   4
typedef struct radar_data
{
char  sRadarName[RADARNAMESIZE];
long size;
DataDate  ddYearMonthDay;
DataTime  dtHourMinuteSecond;
LLBulkData * llBdContent;
short int nRdbType;
short int nRdbSubtype;
}RadarData;

There are hundreds of buffer overruns in GetRadarData() which is probably causing your original complaint. When calling strcpy() or strncop() the destination buffer must be at least 1 byte larger than the number of characters you want to copy. For example, you want to put 2 characters in the Year array, so do this:

char sYear[3]; // enough room for 2 characters plus null terminator

strncpy(sYear,sFileName+3,2);

>> sYear = strncpy(sYear,sFileName+3,2);
The line above may destroy the pointer sYear that was previously allocated if strncpy() fails. See previous code I posted for example of how to correct it. You have to correct all the other small char arrays similarily. If you want to do error checking then do it with some other pointer, such as

if( strncpy(sYear,sFileName+3,2) != sYear)
{
   // error
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

And don't feel bad if someone posts a correction to whatever you said -- none of us are perfect. And you might be supprised at how much I've learned since joining DaniWeb too. Development is a life-long learning process and nobody stops learning.

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

Or one of these

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

Cricket? Is it anything like golf? To my knowledge no one plays cricket here in USA.

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

did you check the return value of bitio_o_open() ? Maybe its returning NULL (or 0) ? If that is ok, then my bet is the problem is somewhere else. Does bitio_o_append() work correctly? How about the function that calls CreateHVFESection0().

Does your program use structures? Are they declared correctly in all program units ? Also check for array bounds errors and buffer overflows, which will both cause wierd problems in unexpected places.

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

>>What's the difference between sending malloced pointer address and sending variable address?
Efficiency mainly. malloc() requires a lot of time and some overhead.

>> Then, when do we need mallocs?
When you don't know the size of something at compile time. For example if you need an array of structures but don't know how many until the program is executed. Also when the size of an object is just too big to be allocated on the stack.

>>size_t nbytes = NULL
No, NULL is used for pointers, not integers. size_t nbytes = 0; >> bitio_o_append(hSec0,0,24);
That line is wrong, the 3d parameter should be sizeof(LONG). Never assume a LONG is a specific size -- always use the sizeof operator to make your program more portable and correct. And the sizeof(LONG) is not 24 in either 32-bit or 64-bit systems, so I don't know where you get the value of 24 from.

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

some questions:
Function CreateHVFESection0().

1. Why is vpSec0 a parameter? It could just as easily be declared locally in the function since it is never used for anything.

2. Why do you bother to malloc nbytes since sizeof(size_t) is only 4 bytes in 32-bit compilers ? Just declare it normally and used the address operator & when used near the bottom of the function.

3. Your function has memory leak because it does not free the memory location returned by bitio_o_close(), as indicated that it needs to do in the function description that follows. You need to add another line free(vpSec0); 4. Since we know nothing about function bitio_o_append() could you please post its function prototype like you did with bitio_o_close()? Maybe the parameters you are sending it are incorrect of wrong type.

I think something has screwed up the stack before calling bitio_o_close(). I would start by commenting out all the calls to bitio_o_append() then rerun and see if the bad pointer problem is corrected. If not then most likely the problem is somewhere else.

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

I didn't get any problems after fixing up the floats, doubles and shorts problems. Also note that main() ALWAYS returns an int. Declaring main() as void may be acceptable to some compilers but it is non-standard.

int main(void)
{

	float net_pay[MAXA] = { 44.0F, 22.0F, 45.88F, 333.467F, 64.77F },
		  integer_part = 0.0F, fractional_part = 0.0F;
    short int x = (short)net_pay[4], Val=0, i=1;
	int cents;

	printf("The Sum ");
	
	fractional_part = modf(net_pay[4], &integer_part);

	cents = (int)(fractional_part * 100.0);
	if( (fractional_part * 100.0) >= (float)cents + 0.5F)
	{
       cents++;
	}
	printf("and %d/100 Dollars\n\n", cents);
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> Could you explain what F means in 0.5F?

F = Float. Without it the default is double and some compilers will produce warning that attempting to assign a double to a float.

>> compiler complains only about integer_part variable
what are the compiler errors/warnings ?

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

Hi! I also received this assignment, but was wondering if someone could help me fix my program (hopefully this constitutes "showing effort"). !

Depends -- is this your work or did you plagarize it from some other source ?

>> don't understand why it will work for relatively small numbers but not bigger ones
Integers can only hold a finite number of digits (see limits.h). So if you try to enter a number bigger than that the program can't work the way you think it should.

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

1) post code. I can't see your monitor from where I sit :)

2) check the 3d decimal place greater than 5. This will probably work, although tested only with the Vista Calculator program.

if( (fractional_part * 100.0) >= (float)cents + 0.5F)
          cents++;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use modf() to extract signed integral and fractional values, then multiply the fractional part by 100 and assign it to an integer

#include <math.h>

<snip>
float fractional_part;
float integer_part;
float number = 999.99;

fractional_part = modf(number, &integer_part);
int cents = (int)(fractional_part * 100.0);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not to mention syntax errors on perfectly legitimate C++, that the old compiler would know nothing about!

Of course it doesn't -- Turbo C is not a C++ compiler.

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

line 11: when declaring the array you have to tell it how many items the array will contain. For example, if you want the array to contain not more than 10 names then declare it like this:

string names[10];

Declaring dynamic arrays is also possible, but apparently your class is not yet at that level, so I'll just ignore that possiblility for now.

lines 12 thru 15: not needed in function main(). The instructions you posted say nothing about doing that. You do need to add a loop in function print() to display each of the names.

Suggestion: don't attempt to do all the instructions at one time. Instead, code and test them one instruction at a time so that you don't get so confused.

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

To be able to create an Exe file in Visual C++ (I hope by your context you are using 6.0) you need to have fairly good knowledge of C++. .

Nope -- only need a very basic knowledge of c++ to write console programs with the compiler. But it does take some time for newbes to learn how to use the IDE. How to do that depends on which version of VC++ you are using -- version 6.0 is a lot different than 2005.

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

depends on the operating system. MS-Windows you can use FindFirstFile() and FindNextFile(). *nix you can use opendir() and readdir(). Or boost libraries have a functions that are portable between operating systems. You can find c++ examples of both in the c++ code snippets here at DaniWeb.

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

You propbably want to use int 21H What you are actually doing is calling interrupt 15H (21) instead of 21H. in line 10.

Good catch. I missed that too. :)

I can't verify that AX = 4C00 is correct because my book is for DOS 2.1

You could however look it up here

Youngstorm: delete line 24 because it overrides the value you set in line 7.

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

It runs ok on my Vista Home, although admittedly I don't write any large programs with it.

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

Interesting ... there have been at least two studies I know about on this topic. One was a few years ago by TV news show concerning the love live of successful, but not necessarily great looking, women. Most of these women were also single and lonely because most men were to scared of them, which goes long with Josh's comment about not being too smart.

The other study I saw just a few days ago in one of those tabloid (smut) magazines -- women who are beautiful, successful, and lonely. Much of their problem was also that men don't want to date such women.

It would seem that very smart and/or very beautiful women turn most men off -- or men are too afraid to approach them. And that probably explains why movie stars date and marry other movie stars. Most men will probably fantisize about being with a great looking movie star, but thats all it is -- a fantisy. In real life we choose a partner who is more like ourselves.

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

Maybe these short tutorials will help

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

yea, that entire paragraph was unreadable

I disagree -- I may be as ancient as the hills by most people's standards here but even I was able to read/understand the post. "...tell me whatz dis" is the only sentence that I could see that might cause some problems (from non-English backgrounds) problems.

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

>>I can call the member functions of tool by just doing an #include "tool.h and the compiler looks for the tool.cpp automatically?

No -- you have to have a project that contains both main.cpp and tool.cpp. Your compiler will compile them separately then link the object files together along with other libraries to creat the final program. There is nothing "automatic" about it. Depending on what compiler you use you have to tell it what *.cpp, object files and libraries to include in the program.


>>How else would you be able to find what you're looking for other than having to resort to grep (or something like it
Some compilers (like Microsoft's) have a browse utility that show you what classes and associated methods are included in the project and contain links to files where they are located. Just clikc on the link and the compiler's IDE will move the cursor direcly to the object. Really great programming tool :)

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

>>Is there an equivalent to SendKeys.Send in C++?

No. C++ language knows nothing (other than what it inherited from C language in stdio.h) about the keyboard because its os specific. You have to use os-specific api function calls to send them one character at a time like jamthwee suggested.

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

look at lines 31 and 33 -- delete that semicolon at the end of those two lines.

>>If I were to do the following, why does it only show the information for Kenez from my inFile?
Only displaying the last line of the file because of the problem with the semicolon on line 33.

You really start to be more careful about where you place those semicolons.

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

moved

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

>Oh dear, Ancient Dragon, you are hard work!!! He he.

Old people have a right to be :) Would like to continue this but have to go to work now.

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

Um, it is fairly obvious that your online parser has a flaw

>If there is a problem you should report it in the Community Feedback board. But I have not seen that in any other posts.

What has this got to do with the daniweb community feedback? Your online code beautifier is the thing that's broken. (Why am I repeating myself again?)

>As you can see it works great for me.

That's great, we all know the daniweb code tagging works fine. But what has this got to do with the online beautifier you are using which is broken?

The reason you have to keep repeating yourself if because you fail to explain what you mean the first time. Yes, you are correct that the problem is that beautifier program. With a little more testing I see that the problem does not occur when I check the "Skip HTML, give me plain code! (Use Save-As function of your browser) " checkbox.

>>This is something I think would be better discussed via PM instead of here.

What is there to discuss. For the time being I will pretend it didn't happen. Please just don't make these mistakes in the future. Be careful with that infraction button you use. Thanx. :)

I will repeat myself again :) That infraction was no mistake -- when you forget to use code tags hit the Edit button and correct it. Anyone with as many posts as you have should know better.

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

Your description sounds like a flag may not be getting set correctly. does your program contain code that is executed when it is minimizes and maximized ? Does the same problem occur with other DirectX programs written by either yourself of someone else (attempting to isolate the problem to either your code of Microsoft's).

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

do you mean computer A controling a USB device on computers B, C, D, ... which are all connected on the same network ? The only way I can imagine that happening is if computer A sends instructions via sockets (or some other way) to a program on the other computers and those computers do whatever is necessary to control their own USB ports.

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

Look at MSDN under CreateFile() and there is a link to serial port communications discussions. Your program can not access the serial ports directly as they could in the days of ancient MS-DOS. Since you have a choice of either assembly or C, then write it in C would be a lot easier.

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

Does anyone bother to actually read my posts these days, cos I find I am just repeating myself.

Ancient Dragon, your online code beautifier is flawed!


It changes all the "< >" symbols to &lt and &gt respectively! So telling the op of for experimenting with html is silly, It is YOUR fault.
.

Ah, my mistake. I though you meant the other way around. If there is a problem you should report it in the Community Feedback board. But I have not seen that in any other posts.

this is a test of html markup parsor for < and > symbol also together like this <>

As you can see it works great for me. Sometimes the parser turns things into smiley faces, but there is a check box to turn off smileys in text posts.

>That was no mistake -- it was intential.
I already told you, it was a mistake, I forgot to add the code tags and then was cut off the internet so I was unable to edit my post in time. Why should I be punished for a mistake?:'(

Another case of miscommunication.

>You promised me you would tell the supermods, but you never did :(

Send me the PM or link where I made that statement because I don't remember it. This is something I think would be better discussed via PM instead of here.

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

I think I have the same problem This thing is driving me crazy. Here's the Hijackthis log. Anyway, I'm new to this and hope someone can help as my antivirus is not removing this problem. Thanks in advance.

Did you trie Crunchie's suggestions ?

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

Um, it is fairly obvious that your online parser has a flaw and it not converting &lt (html syntax into plain text ">"). You shouldn't blame the OP for your mistakes Ancient Dragon.

Its not an error -- to my knowledge (and I could be wrong) the only markup codes recognized are code tags. People are supposed to post ONLY code -- this is not a place to test html code. If someone wants to post C or C++ code that contains html markup code then its his respoinsibility to remove it.

And why is my infraction that you mistakenly gave me still there, did I not ask you to get rid of it:)

That was no mistake -- it was intentional.

I did say this before!

Oh. I didn't realize Dani made you Super Mod.