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

Goto Tools --. Editor Options to change the editor options the way you want them.

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

Turbo C is great for embedded c crap, and great for people who can only afford ancient computers

:mrgreen: :mrgreen: :mrgreen: Its not even good for that because there are several free good modern compilers, such as Dev-C++ that will let you learn c++ as it should be learned. Turbo C is not even good for embeded programs because it only supports MS-DOS 6.X and earlier operating systems.

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

see this tutorial

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

because the keyboard buffer still contains the <Enter> key -- you need to flush that out. One way is like below, which will remove up to 3 keys.

char inbuf[4];
  menu();
  fgets(inbuf,sizeof(inbuf),stdin);
  //scanf("%c",&choise);
  choise = inbuf[0];
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what's wrong with the Dev-C++ compiler? It compiles both C and C++ ok. If you want it to compile C only, then make the filename extension *.c instead of *.cpp

Myself, I like Microsoft compilers better because they have better debugging tools. You can still get VC++ 2005 Express for free.

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

what's the difference between deep copy and shallow copy or not so deep copy :rolleyes:

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

thanks again
How come those people in Redmond Washington did't think of writing that
in their HWND description?

They did tell you -- if you look in the right place. It's just normal c++ inheritance -- the average learning curve to get everything straight in your head is about one year. :eek: So don't feel too bad if you are lost at first -- we all are.

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

Toss out all that C code and replace it with c++. use std::string and >> insert operator and you don't have to do any tokenizing at all. Here's an example

#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
using namespace std;


int main()
{
	string word;
	// stay in the loop until you press Ctrl+Z <Enter>
	while( cin >> word )
	{
		// convert the word to lower-case
		transform(word.begin(),word.end(),word.begin(),::tolower);
		// now find the word in the database (not shown here)
		cout << word << endl;
	}
	cout << "done " << endl;
	return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

#include<iostream.h>
#include<string.h>
#include<fstream.h>

You must be using an ancient c++ compiler -- maybe Turbo C++? If you want to learn c++ language you will have to toss that compiler into the bit bucket and get a modern one -- Dev-C++ is a good one.

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

are you using MFC? If you are, then the every window has an m_hWnd object, which is the HWND you need.

CMyWindow::MyFunction()
{
    SomeQcard32Function(m_hWnd, /* other parameters here */);
}

If you are writing pure win32 api then CreateWindow() or CreateWindowEx() returns the HWND.

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

Problem 1: __declspec (dllexport) is only used in the dll to identify those functions or c++ classes that need to be visible to the outside world (i.e. application program or other dlls.). use __declspec (dllimport) in the function prototype in application programs.

int __declspec (dllimport)  foo(); // function prototype

int main()
{
   foo();
}

Problem 2: DLLs normally (but not always) come with a .lib file -- link with the .lib file if you use __declspec (dllimport) shown above. There is an alternative called "dynamic linking" which does not link to a library at all, but used LoadLibrary() to load the DLL into memory.

Problem 3: If you are writing a wn32 program you should already have the HWND of the window the program created. If, however, you are writng a console program, then you can use GetConsoleWindow(), which returns the HWND of the console window. If your program does not even have a console window, then you are SOL. Note: VC++ 6.0 has a bug -- GetConsoleWindow() is undefined in the header file -- either prototype it yourself or download the Windows Platform SDK, which contains the correction. It is ok in Dev-C++ too.

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

There are probably a number of ways to solve that. The solution I took was to create another listener thread. The main program thread sends a message to this listerner thread every keyboard and mouse event. The listner thread waiks up from Sleep() every minute and checks its input queue. If nothing then it knows there has been no keyboard or mouse activity during the last minute and can take appropriate actions.

You might also use SetTimer() and and capture WM_TIMER events. The os will call a function of your choice after the specified amount of time has elapsed. The main program could have a counter that increments each time a keyboard or mouse event occurs, then the timer function just checks that counter -- if counter is zero then there were no events.

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

That link has nothing to do with finding the global extremum, which is located at -b/2a. (If a = 0 then there is no global extremum.)

sorry, I thought you wanted to know how to calculate quadritic equation. Beyond that, I don't have a clue how to solve your problem.

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

see this article

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
#include <stdio.h>
int x;
int y;
int a,b,c; 

int main()
{
   // put your code here


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

That's a far more complex solution to the op's problem than it needs to be. There is a pretty simple solution that takes only a few lines of code. Just think about loops and how to search an array for a certain value.

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

For a freestanding implementation, I have indeed worked with CHAR_BIT of 16. .

But I'll bet UCHAR_MAX value is still 255 (not referring to UNICODE wchar_t).

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

Ok Can u please help me i swear this is not my homework and only a creation of mine.please help me.it is therein help....lib management program...:rolleyes:
I have created it on my own i swear:eek:

Cool -- why are you hijacking this thread? you already have your own thread.

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

huh ,
I cnt do it ..

Didn't your momma ever tell you that "can't" never did anything:cheesy:

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

it was a general c++ program.

No it isn't. A c++ program does not use stdio.h, string.h and many of the other header files that are in your program. Nor does a c++ program use printf(). And rarly do they use structures. In fact, your program does not contain even ONE line of c++ code.

you still have not posted any errors

And please use code tage, not php tags. For some reason I can't copy that into my clipboard.

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

Yes i think thats correct but to help someone is not wrong

True -- but the OP didn't ask for our help, just stated a problem.:rolleyes:

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

that is NOT a c++ program. Its a C program.

What are the errors? Post them.

And you really really need to develop a decent program coding style. Starting everything at the beginning of the line is just plain lazy and horrible. Nobody is going to read that stuff.

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

David, I know you are right about that, but have you ever heard of an os where the max value is anything other than 255? There could be one, but it is probably so obscure hardly anyone uses it.

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

you can find the exact example of that in Microsoft Scribble tutorial. See www.mscn.microsoft and search for "Scribble Tutorial". It will show how to just draw straight lines but might be expanded to include other shapes too.

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

the unsigned char data type has a range of 0 to (and including) 255. So all you need is an int array of that size to count the number of occurences of all characters. Initialize the array to all 0s then use the char itself as the index into the array.

int counts[255] = {0};
char letters[]= "aabceqoiwer'pojadgojzfgoijwef";
int i;
for(i = 0; letters[i]; i++)
   counts[letters[i]]++;

now all you have to so is search the array counts[] for non-zero values and you have the counts you want.

If you were using a modern c++ compiler then there would be c++ <map> class that would work better.

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

in here the words j appear second time again in my words series and o also. may be it might be better to check not to repeat the words.So how can i do?

check the array to see if the char is already in it. If not, add it to the array, otherwise if its already there then just generate another random char.

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

If you are that new to C/C++ then maybe you should concentrate your efforts on learning the language instead of diving right into very deap waters that are far beyond your current knowledge and abilities. There is lots of information on www.mysql.com, including links to blogs and message boards. you will get more (better) information from them than you will here. For example you should study their documentation thoroughly, section 22 discusses API functions and libraries.

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

you can try google for ODBC

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
for ( i = 0; i < n; ++i )
   {
      for ( j = i; j < n; ++j )

that is a waste of cpu cycles because it compares the first array element with itself. array is the same as array[j]

for ( i = 0; i < n-1; ++i )
   {
      for ( j = i+1; j < n; ++j )

The above changes makes the bubble sort run a few micro-milliseconds faster because it avoids unnecessary loop iterations and variable comparisons. This could make a more significant difference when comparing strings or other complex data types.

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

If you want to learn C language then do not use hardware that only supports a subset of the language. For example you would learn next to nothing about file i/o or console programming because PDA and Palm do not have a console. They do not have environments, so getenv() is useless. They don't support the concept of current directory, so functions such as getcwd() and drive letters are useless. And these limitations are only the beginning.

If you are doing this only for your own personal achievement, then go ahead and do whatever turns you on, but later on you will probably regret it.

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

That's one of the many many dangers of writing programs in Turbo C/C++ -- it ain't portable to other operating systems or other compilers! You need to do a total, 100% rewrite of that program if you want to compile it with any modern 32-bit compiler because none of them -- not one -- supports those old, ancient, obsolete Turbo C functions. You have one of two choices: (1) stick with Turbo C and put of with all its limitations, or (2) completly rewrite the program.

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

neither -- If you want to learn C then write console programs for the PC because PDA and Palm do not support the full set of C language. And because PC programs are a whole lot easier to debug.

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

you probably need to set the baud rate, stop bits, data bits, and parity. See MSDN about how to configure the port.

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

you missed the point. Create only ONE structure that contains the weather data. Then instantiate an array of 12 of these structures.

struct weather
{
   int rainfall;
   int high_temp;
   int low_temp;
};

weather array[12];

In the above, array[0] = January, array[1] = February ... array[11] = December.

In main() the program should have a for loop that counts from 0 to 12 (once for each month) and inside the loop ask for the values of rainfall, high_temp and low_temp, then put these values in the array.


After you get the above working, you need to make another three integers to hold the total rainfall, highest temp and lowest temp so that you can display these values after the loop has finished. These three values should also be calculated inside the loop. Do not prompt the user for these values -- they are computed based on the answer to the other three questions.

Salem commented: Good post +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Assuming MS-Windows os, use SetLocal and the os will make the conversion for you when the values are read from the file.

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

you need to know a bit about mixed language programming and C calling conventions.

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

iostream.h is obsolete. Use <iostream> (without .h extension). The iostream class was changed somewhat. If you are using an ancient compiler that does not have <iostream> then you should upgrade to a newer compiler. Any attenpt to use iostreams with ancient compilers will teach you nothing at all about modern c++ standards.

I feel your pain about using stdio.h functions -- I too occasionally resort to printf() when complex formatting is needed.

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

>>If I want to generate random numbers between -1 and 1

Why? The only number between -1 and 1 is 0. -1, 0 and 1 are all integers, there are no fractions in integer math. rand() returns an integer. So if you want a float return value, such as 0.123 then you will have to write a function that puts the return value from rand() into a float variable then divide it by RAND_MAX (defined in stdlib.h) to make it less than 1. I'm not sure how to make a random number between -1.0 and 0 other than just simply arbitrarily make the result from the above calculations negative.

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

>>But asking about weakpoints means nothing unless you mention a specific task

And one person's idea of a weak point is another person's idea of a strength. The old adage "One man's trash is another man's treasure" comes to mind.

>>No call-with-current-continuation. No closures
Like to explain what that means?

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

This code is in the CDialog class that contains the button.

CWnd* pWnd = (CWnd*)GetDlgItem(IDC_Pervious);
pWnd->EnableWindow(FALSE);

I cannot access the link you posted from where I am at. You might want to zip up the file and attach the zip file to your post.

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

assume you used ClassWizard to name the button control m_ctrlButton,

m_ctrlButton.EnableWindow(FALSE); // grey (disable) the button
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why is printstring using printf() to print only one character at a time??? Thats an awful wast of processing CPU cycles. You could do it all in one line. First, you know there will be four strings for each line, and each column will start at a constant column number. If you divide 80 by 4 then each column must be 80/4 = 20 characters. So let N be the width of each column, or 20 in this case. What you need to do is print each of the 4 strings in a column of 20 characters, and you can do that like this

Using the first line in your example:

char* c1 = "SENT:";
char *c2 = ".WORD";
char *c3 = "0";
char *c4 = "; Initializes the sentinel as 0...";
int N = 20;
printf("%-*s%-*s%-*s%-*s",N,c1,N,c2,N,c3,N,c4);

The '-' in the format string tells printf() to left-justify the text, the '*' means to get the width of the column from the parameter list, and 's' means it is to print a null-terminated string. Now, you will need to replace N in the code above with whatever the user enters as the column width. If the string is longer than the specifiec column width, printf() will ignore the column width and print the whole string.

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

Hi everybody

Can you please explain me the weakpoints of c++ language?

there are none. The language will allow you to do anything you want to your computer -- even burn it up if you want it to.

I think it is very difficult to create GUI in C++, isn't it?

yes

I also would like to know is there any method to combine C++ program and Java Program.

java programs can call C functions, but I have not figured out how to call Java from C or C++. It may not even be possible, I don't know. I'm not a java programmer -- just repeating what I've read and heard co-workers say.

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

If you are writng a C program, use fgets() to get the string from the keyboard because it will not permit buffer overflow. Your version of the function has the same problem as gets() -- it will just scribble all over memory when you enter more characters than can be put into the array. Most (if not all) experienced programmers will not use gets() for that reason.

readstring(char s[], int arraysize) 
{
   fgets(s,arraysize,stdin);
}

You should edit your post to use code tags -- very few people will bother to wade through very much unformatted c code.

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

MS-Windows is not a real-time operating system, so you can't get any better accuracy then a couple hundred milliseconds. If you want microseconds, then you have to use a different real-time os. One reason is that it takes the os thread scheduler a few milliseconds just to switch threads and do other os maintenance. Then of course other programs may not play nice and hog more cpu time than they probably should, and there are some operations that cannot be interrupted, such as disk i/o -- you have no control over any of those events.

I saw an add-on a few years ago that would emulate real-time, but it cost quite a few $$$.

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

hint: look for function Sleep() which uses milliseconds. And 100 is about as accurate as it can get, depending on what other processes are running on the computer.

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

Hi I was just wondering how you change the text colour of only some of the text in a console when you are using cout to display your text.

it will all depend on the operating system. MS-Windows, use win32 api console functions. I don't know about *nix but probably use a curses library. You can download some free examples from here

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

This is a good tutorial about how to write non-MFC programs. It shows you how to create dialog boxes from scratch. You could integrate some of it into an MFC program if you want. And here is a good non-MFC XMessageBox that can be easily added to an MFC program (I have already done that), and it works very well.

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

>> if(Board[row][cur_col] == Board[row + 1][cur_col- 1] && Board[row + 1][cur_col - 1] == Board[row + 2][cur_col - 2] && Board[row + 2][cur_col - 2] == Board[row + 3][cur_col - 3])


when row == 5 the above causes exception because Board[row+1] is illegal cell reference. I responded with 1 to the question "PlayerO please enter the column in which you would like your marker placed". variable i is hardcoded to = 5 in main(), which may explain the problem.

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

>> while (reply,reply1,reply2,reply3,reply4!= "no")

that is not necessary. just create a for loop that counts from 0 to 5 -- no need to answer that question 5 times

for(int count = 0; count < 5; count++)
{
   // blabla
}

there is no need for num1, num2 ... num5 either. just enter the numbers directly into the array. add this to the above loop

cin >> intarray;

intarray needs to be declared as an array of 6 integers, not 5

int intarray[6]