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

Install VC++ Create a MFC application it is quite easy.

The current free compiler VC++ 2008 Express does not support MFC. You will have to buy it do get MFC.

VC++6.0 does support MFC ok but that is a terrible compiler because it doesn't support the C++ language very well so parts of C++ you probably already have learned can't be used by that compiler because the compiler is too old.

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

I am not an expert but i am trying to learn .

I dont understand something in the program.

&rea 's code

unsigned int* RegionToArray(System::Drawing::Bitmap^ binaryImage,unsigned int coordinate_x, unsigned int coordinate_y, unsigned int width_rect, unsigned int height_rect){
coordinate_x=this->coordinate_x;
coordinate_y=this->coordinate_y;
width_rect=this->width_rect;
height_rect=this->height_rect;

Well If the function is a class member i dont understand why &rea used all the variables as Arguements when they can be accessed using this ->

The function parameters coordinate_x, coordinate_y. width_rect, and height_rect are not class members but are passed into the function by somethig else, which was not posted. The statement you quoted is just copying them into the class variables.

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

Just guessing here, but do you want main() to call a function that is another *.cpp file? For example,

// foo.cpp
#include <iostream>
int foo()
{
    std::cout << "Hello World\n";
    return 0;
}
// main.cpp
extern int foo();
int main()
{
    foo();
    return 0;
}

Now you have to compile main.cpp and foo.cpp then link the object files together to get a single executable program. Exactly how to do that depends on the compiler you are using because each one is different.

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

put a print statement at the beginning of the function to print out the value of height_rect and width_rect. Are they what you would expect? If not then the problem is elsewhere in your program.

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

Well let me assure you I have enough command over the English language but its just that my generation is probably more used to converse in the "SMS lingo". If you have a problem understanding my language there is a more gracious way of saying so rather than adopting a condescending tone like you just did(or the guy before you). I appreciate the fact that you are trying to help me but please understand that I am just an amateur & not an expert like you all.

There are many people here from non-English speaking countries and leek speak is difficult if not impossible for them to read. Hell, I even have trouble reading your posts. Please read DaniWeb Rules -- the link is at the top of every page. And any further posts about this matter will get this thread closed.

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

line 10 doesn't allocate room for the null terminator. Add 1 to the size() value.

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

Here is how I would allocate A

const int maxelms = 4;
int i;
double** A;
// allocate the first dimension
A = calloc(maxelms, sizeof(double *));
// now allocate each of the other dimensions
for(i = 0; i < maxelsms; ++i)
{
   A[i] = calloc(maxnums, sizeof(double));
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The open flags do not set the file permissions -- they are two completly different things. After copying the file you have to change the permissions. Here's how to do it.

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

The header file and line 62 of the *.cpp file are incorrect. The parameter you have declared is just one single character -- I know of no names that consist of a single character.
It should be this: void DisplayName (char* pFullName); or this void DisplayName (char pFullName[]);

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

>>there's other ways to do it... (No one seems to remember how for some reason though)

If you are running MS-DOS or MS-Windows some compilers have console functions in conio.h that will help -- _kbhit() tests if a key is available at the keyboard and getche() gets one character. Put those in a loop and you can do other processing while there are no keys available at the keyboard.

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

yes. add cin.get() just before returning form main().

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

Two problems

1) don't use getche() -- instead use cin.get()

2) after receiving input for integers or a single character you are leaving the '\n' <Enter> in the keyboard buffer. That has to be flushed out because it causes great problems. The easiest way to do it is cin.ignore() But a more accurate method is described by Narue in her post at the top of this c++ board. Add that code in appropriate places and you problem will be solved.

3) You also need to change the loop in the Display() function like you did in the Edit() function.

Traicey commented: Im sure Reputations dont excite you anymore, ur used to them +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to create another thread so that user input is in the main thread and other processing is done in the other thread.

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

you can attach them to your post. Press the Go Advanced button then the Manage Attachments button that appears towards the bottom of the page.

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

Are you talking about the c language itself or console program window ? The problem has nothing to do with c language. Even if you run cmd.com to get a console window then maximize it, the window may not cover the entire monitor canvas, depending on the pixel settings you have set on your monitor.

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

lines 19-23 can be rewritten like below because it isn't necessary to test for eof directly. while( Infile >> N >> A >> G) delete line 63 if you recode as above

Other than the above, I don't know what kind of help you want.

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

What you want is a simple line drawing program. How to do it depends on the operating system because each one is different. And all of them are somewhat complex.

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

You have to be very careful about the code you get off the net because a lot of it is written for ancient 16-bit compilers on MS-DOS version 6.X and earlier operating systems. You might as well scrap that second code you found because it won't work on modern 32-bit compilers or MS-Windows.

As for the first program you posted, I don't know what compiler/os that was written for because it contains a lot of stuff I've never encountered before. So you might as well scrap that code too.

For MS-Windows, all you need to do is use the communications functions that are described in Communications Resources. You will want to create a thread for each port you want to monitor and do the reading from there.

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

>>scores[26] == scores[26]<24 ? in : in;
I have no clue what that is trying to do

There are 8 sets of values that the scores can fall into, not 32. So all you need is an array of 8. When you read a score just use a series of if statements to determine which of the 8 array elements it will fall into

int scores[8] = {0}; // initialize all elements to 0

// for each value read from the file, do this:
    if( value < 25) 
        score[0]++;
   else if( value < 50)
        score[1]++;
   else if( value < 75)
        score[2]++;
   // etc. etc for all remaining ranges
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try this: obj.setvalue( &FB );

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
for (int i = 0; *data != '\0' && i < length; ++i)
{
strcat(first,data);
data++;
}
std::cout << '\n';
}

You can not use strcat() that way because it copies the entire source string to the destination buffer, not just a single character. If you want to copy just a single character than just use simple assignment

char* ptr = first;
for (int i = 0; *data != '\0' && i < length; ++i)
{
      *ptr++ = *data++;
}
*ptr = 0; // null terminate the string
std::cout << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have to allocate memory for pointer a. The way you have it written pointer a just points to some random memory location that your program probably does not own.

char *p = "asd";
 char * a = new char[strlen(p)+1];

The second reason your program doesn't work is because you are using strcat() incorrectly. You don't need the loop if you use that function.

char *p = "asd";
 char * a = new char[strlen(p)+1];
a[0] = '\0'; // initialize to null string
strcat(a,p);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It is not possible to start a new GUI program without a window. It only works for console programs.

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

Didn't the startup params in CreateProcess() work?

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

use the mod operator % to get a value from 0 to some upper-limit. For example to get a random number between 0 and 100 int num = rand() % 100; Much more information about it here.

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

you might have to consider some additional software that converts MS-Windows into a real time os -- this one for examplehttp://www.tenasys.com/products/intime.php

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

when I click that link all I get is this:

test - opawb01

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

Try redrawing the original graph with the same color as the background so that the lines will get erased, then draw the new graph.

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

the best time of year for Disney World is just after it burns down.
No more fake happiness, and the inevitable lawsuits haven't started yet.

Its obvious you have never been there. If you do make sure to take lots and lots of money and plan to visit the other sites in the area. But don't go during hurricane season because its not pleasant place to be during the storms.

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

On Windows, check out QueryPerformanceCounter() and QueryPerformanceFrequency().

those are not system delay functions.

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

<iostream.h> was declared deprecated

More about that here.

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

Sometimes you have to read MSDN a million times before fully comprehending it.

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

you also have to specify dwFlags member of that structure startup.dwFlags = STARTF_USESHOWWINDOW; Read the description in MSDN instead of blindly trying to use something you know nothing about.

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

>>There should be no difference between single thread and more threads acquiring semaphore
Maybe you don't think so, but there is a big difference.

Its working correctly -- Read the MSDN description for that function and you will see that it doesn't block after the first call when called from within the same thread.

The thread that owns a mutex can specify the same mutex in repeated wait function calls without blocking its execution

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

>>now is there a way to hide this window
Yes -- CreateProcess() has a parameter that does that. See the STARTUPINFO structure.

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

depends on the hardware that linex is running on -- if its on an 80x86 or Pentium box then there will be no difference at all. Linex (or unix) is supported on a lot of other platforms and the assembly instructions for those will be very different than on ms-windows. To complicate things a bit more, if and when Microsoft ports MS-Windows to other platforms the assembly code for MS-Windows will change accordingly too.

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

>>i believe it better than winsock so i really dont care.
No it isn't -- the code you posted IS using winsock, it does not replace it. There is nothing wrong with using libraries that make your life a little easier, all programmers do that.

>>everything i've learnt, ive learnt myself.
Admiral achievement, but it will take you years to unlearn all the terrible code examples that you find on the net and in many very old books.

Here are a few links you should read. Scroll down and you will find links to other very helpful pages.

>>So can you help or not?
No.

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

Post code because its a bit hard for us to see the program you wrote on your monitor.

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

>>I was wondering how can I make a precise delay that is shorter then 1ms
depends on the operating system. Neither MS-Windows nor *nix will allow you to do that because neither operating systems are real-time os. There are a lot of other programs that have to be executed as well as yours and they all require cpu time. Its just not possible to devote that much time to just one process. You could give your program a higher priority but you risk the danger of halting the entire operating system when you do that.

Even though the delay functions have a resolution of 1 ms its very unlikely that will be achieved in real tests -- normally do not expect a better resolution than about 10 ms or so, depending on what other processes are doing.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
  • RegOpenKey() to open the key
  • RegEnumValue() to read the value directly into the string
  • CloseKey() to close the key object

Registry Fucntions here.

Example program here

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

I don't know about the math you described, but the program is wrong

{vector<Pair> set;

\\input of the set of points, with 50 points
Pair* a1 = new Pair(70, 64); set.push_back(*a1);

you don't need all those memory allocations. Its probably causing a huge memory leek and just overcomplicating your program. All you need is a single Pair object, set the values and push onto the vector. Just add a Set() method that takes the same two parameters as the constructor.

{vector<Pair> set;

\\input of the set of points, with 50 points
Pair a1;
a1.set(70,64); set.push_back(a1);
a1.set(3,11); set.push_back(a1);
// etc etc

And you can save yourself a lot more typing by just creating a simple array instead of that vector

int set[][2] = {
    {70,64},
    {3,11},
    {43,35},
    {67,97},
    {95,71}
    // etc, etc
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Mutexs work with multiple threads or multiple processes. What you describe is not a problem if there are no other threads or processes that want access to the mutex at the same time. Add a Sleep() before the WaitForSingleObject() to allow time for other threads to gain access to the mutex and see if the wait function blocks until the other thread(s) have released the mutex.

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

>>the problem is I not allowed to use arrays.
vector is an array.

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

read a random number into a float between the range of 0 and 100, then divide by 100 to get a number from 0 to 0.9999

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

Since you didn't post any code we can only guess that you are attempting to write back to the file that you read from. You can't do it that way. Open a different file for output then read a character from input file and write the morse code to the new output file.

BTW you don't need an interator. Depending on how you set up the vector you can index directly into the vector using the english character as the index value. Example: string code = array['A'];

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

This is the day that Americans honor our dead soldiers for the ultimate gift of life that they gave us. We have outdoor barbecues, drink beer, have large televised parades, and visit fallen soldiers at their grave sites.

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

Here is the c++ way of doing that

#include<iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;

class X
{
public:
    string a;
    string b;
    string c;
};

int main()
{
    string abc = "as,df,ert:we,rt,yu:ee,rr,tt";
    vector<X> vtr;
    X xx;
    size_t pos;
    while( (pos = abc.find(':')) != string::npos)
    {
        string s = abc.substr(0,pos);
        abc = abc.substr(pos+1);
        stringstream str(s);
        getline(str,xx.a,',');
        getline(str,xx.b,',');
        getline(str,xx.c);
        vtr.push_back(xx);
    }
    return 0;
}

If you are looking for a C solution then post your question in the C board.

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

DataReel.lib is free and portable to both *nix and MS-Windows. It has a huge amount of functions to do networking and other stuff.

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

delete line 17 because it is a do-nothing line.

line 18 is pushing a pointer to an object that disappears from scope as soon as the function returns to main() -- the pointers are immediately invalidated. Why use a vector of pointers anyway? Just do this: vector<string> vect; and everything will work as you expect.

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

Opps, I just realized I posted this in the C forum ;) I thought I was in C++.

You posted in the right place. It doesn't matter what compiler you use, its the code not the compiler that determines which board to post on.

[edit]Oops! I see the cout now. Oh well, not that hard to substitute printf()