mitrmkar 1,056 Posting Virtuoso

You need to use an infile.clear() call, since you are working with same ifstream object throughout the program. See
http://www.cplusplus.com/reference/iostream/ios/clear.html
Try also to understand and learn how to use the eof(), fail(), good() functions.

case 7:
infile.open(myFile.c_str(), ios::in);
[B]infile.clear();[/B]

Note that, when you add words to the file, add a newline also, otherwise you'll have just one long word.

mitrmkar 1,056 Posting Virtuoso

Are you sure that the file actually contains any data?

A minor note, in your 'case 7' block, the 'continue;' is inside the if block which checks whether the infile is open, you should move 'continue;' outside of the if block.

mitrmkar 1,056 Posting Virtuoso

If you have a graphical debugger, i.e. one with a GUI, then use the debugger to step through your code one line at a time to realize how your code actually works. You can see/watch contents of the variables as you debug, I think that might prove helpful too.

mitrmkar 1,056 Posting Virtuoso

bomb

mitrmkar 1,056 Posting Virtuoso

Instead of

this->richTextBox1->Select( richTextBox1->Text->IndexOf("how"), 3);

use

this->richTextBox1->Select( [B]startPos[/B], 3);

i.e. you were simply always getting the first index of the string 'how'.

mitrmkar 1,056 Posting Virtuoso

You have a major problem regarding scope of variables in C/C++. Lookup and study information on that subject very closely. Even better is, if you make simple tests to really understand how variables (including arrays) get created and destroyed in a program.

Instead of pointing out the errors in the program, I thought to write a couple of functions trying to demonstrate you how the overall structure of your program might be.
There is no two-dimensional array involved but I hope you get some ideas that you can employ and make progress. So here it goes ...

// This many vehicles at max, you can redefine it to e.g. 
// 10 whenever you want, it won't break anything
const int Vehicles = 2;

// struct VehicleInfo withholds information needed 
// for a single vehicle
struct VehicleInfo 
{
	double HoursParked;
	double Cost;
};
// Function prototypes
void GetInformation(VehicleInfo Info[], const int Count);
void CalcCost(VehicleInfo & Info);
void DisplayTotals(VehicleInfo Info[], const int Count);

void GetInformation(VehicleInfo Info[], const int Count)
{
	// Get the user input (hours) for each
        // vehicle and calculate the cost

	for(int ii = 0; ii < Count; ++ii)
	{
		cout
			<< "Enter the total amount of hours car # "
			<< ii
			<<" was parked in the garage (ex: 2.5) ";

		// Store the value directly in the array
		cin >> Info[ii].HoursParked;

		// Calculate the cost for the current vehicle
		CalcCost(Info[ii]);
	}
}

void CalcCost(VehicleInfo & Info)
{
	// Calculates the cost for one vehicle …
mitrmkar 1,056 Posting Virtuoso

For a single error (ERRORC) it goes like this ...

do 
{
    // do something ...
}
while(-0.1 > ERRORC || 0.1 < ERRORC);
mitrmkar 1,056 Posting Virtuoso

You have to use the IndexOf() in a loop, like

for(int startPos = richTextBox1->Text->IndexOf("how");
     -1 != startPos;
     startPos = richTextBox1->Text->IndexOf("how", startPos + 3))
{
    // something here
}
mitrmkar 1,056 Posting Virtuoso

In your THREEDICE.H add the following forward declaration

#define THREEDICE_H
[B]class onedie;[/B]
class threedice
...

Then the statistics() function is a bit odd, if you think it will be called from e.g. main(),
it probably should look like

int main()
{
    const int roll_count = 200;
    int rolls[roll_count] = {0};
    // I'm not actually sure what the allresults should be
    int allresults[roll_count] = {0}; 
    // Then you can make the statistics() call ...
    statistics (rolls, roll_count, allresults);
    return 0;
}

void statistics (int rolls[], int count, int allresults[])
{
    threedice tryerluck;
    for(int i=0;i<count;i++)
    {
        tryerluck.rollem();
        rolls[i]= tryerluck.getsumFaces();
    }

    // and maybe do something here with the allresults too    
}
mitrmkar 1,056 Posting Virtuoso

I think you could use directly the IndexOf() method, i.e
richtextBox1->Text->IndexOf("how")
and once you get the index (or -1, if not found), you probably already know how to select the text in a TextBox.

mitrmkar 1,056 Posting Virtuoso

At least one semicolon seems to be missing ...

int threedice::getsumFaces()
{
         return die1.getroll()+die2.getroll()+die3.getroll() [B];[/B] 
}
mitrmkar 1,056 Posting Virtuoso

I am still leaking memory =[

The _itoa_s() did not actually have much to do with the memory leaking, it was just a safety measure so that your program will not crash.

About the memory leaks, I think there's at least two places where it happens

1) For each SetTimer() call there should to be counterpart KillTimer() to use the timer resources properly.
2) You are not calling ReleaseDC(hwnd, hdc) in your WM_ERASEBKGND handler, i.e. every hdc you get using GetDC() is to be released by ReleaseDC(hwnd, hdc).

mitrmkar 1,056 Posting Virtuoso

Because of the way how you use _itoa_s(...) and the related buffers, _score, _tempscore and val, the program runs currently on good luck.
You could change all the _itoa_s() calls to use a single array of chars of sufficient size,
i.e.

static char itoa_conv_buff[MAX_BUF_LEN_HERE];
_itoa_s(num, itoa_conv_buff, MAX_BUF_LEN_HERE, 10);
mitrmkar 1,056 Posting Virtuoso
if(packe[q].strinput[0] == ' ') 
{
    q++;
    // Because you have incremented q by one,
    // the fprintf() call below is guaranteed to produce
    // unwanted output ...
}

// You must change your code so that you know whether to use 
// packe[q].strinput or packe[q - 1].strinput ...
fprintf(creafile, "%d %s \n", timeslot1[i],  packe[q].strinput);
mitrmkar 1,056 Posting Virtuoso

You are trying to use a string "\0" there, instead you have to use '\0', i.e.

if (x==strlen(a))
    current[x+1] = '\0';

and be careful not to access indexes that are out of bounds.

mitrmkar 1,056 Posting Virtuoso

You might also make use of the strstr() function
http://www.cplusplus.com/reference/clibrary/cstring/strstr.html

mitrmkar 1,056 Posting Virtuoso

Bjarne Stroustrup's comments on the void main() -subject can be read here ...
http://www.research.att.com/~bs/bs_faq2.html#void-main

mitrmkar 1,056 Posting Virtuoso
if( one == 'o' && two == 'l' && three == 'l' && four == 'e' && five == 'h' )
{
    
    // Select only as many characters as in string 'hello'
    //  i.e. [B]five[/B] ...
    this->richTextBox1->Select((positionen - 5), [B]5[/B]);

    this->richTextBox1->SelectionColor = Color::Red;
    MessageBox::Show(this->richTextBox1->SelectedText);
}
mitrmkar 1,056 Posting Virtuoso

You are misusing fscanf() to scan the integers, you need to apply the address-of operator &

for(int i=0; i<max_terms;i++)
{
    fscanf(finput,"%d", [B]&[/B]timeslot1[i]);
    fgets(packe[q].strinput, 32, finput);

    if(packe[q].strinput[0]!='\n') q++;

    fscanf(fcommand,"%d", [B]&[/B]timeslot2[i]);

    fgets(comm[i].strcommand, 24, fcommand);

    // Note that you may have incremented q by one, above,
    // whenever that is the case, what does packe[q].strinput 
    // contain at this point?
    cout<<packe[q].strinput<<endl<<comm[i].strcommand<<endl;
}
mitrmkar 1,056 Posting Virtuoso

whole

mitrmkar 1,056 Posting Virtuoso

holy

mitrmkar 1,056 Posting Virtuoso

Strange if it does not compile,
maybe you have added the handler in a 'wrong' way.

To add the handler for the KeyUp event,
1) Select the textbox control on your form
2) right-click and select Properties
3) double-click on the row which reads "KeyUp"
=> the editor creates the handler for you
4) type in the code and compile

mitrmkar 1,056 Posting Virtuoso

Am I on the right track or have I missed something.

You have now missed something, you are trying to access the KeyCode in wrong handler (TextChanged).

Instead, for e.g. the KeyUp event, use ...

private: System::Void textBox1_KeyUp(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e)
{
	if(Keys::C == e->KeyCode)
	{
              // Do something here ...
	}
}
mitrmkar 1,056 Posting Virtuoso

This is probably what you are after ...

<snip>
ofstream DataFile3("C:\\Documents and Settings\\ttrusse\\Desktop\\Algeciras\\C++\\results.txt");

cout<<"Writing...Please wait...."<<endl;
cin.get();

for (a=0; a<Search.size(); a++) 
{
    // [B]No ostringstream is needed here[/B], 
    // instead output directly to the file ...
    DataFile3 
               << Search[a].date 
               << Search[a].time
               << Search[a].wind_obs 
               << Search[a].wind_sensor
               << endl;  
}
return 0;
}
mitrmkar 1,056 Posting Virtuoso

Just pointing out the fact that in C/C++, array indexes are zero-based.
A simple example

#define NUM_ELEMENTS 3
int Quantity[NUM_ELEMENTS];  // An array of three integers

// Assign a value to each element
Quantity[0] = 123;
Quantity[1] = 456;
Quantity[2] = 789;

// Now, to output all elements, last valid index is 
// (NUM_ELEMENTS - 1) instead of NUM_ELEMENTS, so ..
for(int nn = 0; nn [B]<[/B] NUM_ELEMENTS; ++nn)
{
     cout << "value at[" << nn << "] = " << Quantity[nn] << "\n";
}
mitrmkar 1,056 Posting Virtuoso

Could it be that you have not escaped backslashes in your string?
I.e. in your code the string should be:

const char regex[] = "^\\[\\d{4}\\-\\d{2}\\-\\d{2}\\s\\d{2}\\:\\d{2}\\:\\d{2}\\.\\d{3}\\]\\s\\w*\\s*\\w*\\.+\\w*\\:\\d{4}\\sHello"
mitrmkar 1,056 Posting Virtuoso

You can use the SelectionStart TextBox's property for that purpose.
Also closely related is the SelectionLength i.e. how many characters the selection spans (if any).
As an example, to place the cursor in front of the second character without selected text, you could use

textBox1->SelectionStart = 1;
textBox1->SelectionLength = 0;
mitrmkar 1,056 Posting Virtuoso

Get the dependency walker from
http://www.dependencywalker.com/
and see whether your program actually needs one or more .dlls that you are not aware of.

mitrmkar 1,056 Posting Virtuoso

are you threatening me????

Of course not, just some sense of humour ... so relax.

mitrmkar 1,056 Posting Virtuoso

You have to escape all backslashes in the file path, i.e.
instead of

ofstream DataFile3("C:\Documents and Settings\ttrusse\Desktop\Algeciras\C++\results.txt");

use

ofstream DataFile3("C:\\Documents and Settings\\ttrusse\\Desktop\\Algeciras\\C++\\results.txt");

Didn't your compiler give any warnings??

mitrmkar 1,056 Posting Virtuoso

LOL you kids, i swear

how about you send me $500 to my PayPal account and I'll won't track your IP address and tell your teacher what you're up to..

Hmmm ... your post could be moved to a blackmail forum, if one existed ...

mitrmkar 1,056 Posting Virtuoso

If you add an TextChanged handler to your form, you can change the color of the TextBox's (whole) text as follows:

if(textBox1->Text == "red")
{
    textBox1->ForeColor = System::Drawing::Color::Red;
}
else if(textBox1->Text == "blue")
{
    textBox1->ForeColor = System::Drawing::Color::Blue;
}
else
{
    textBox1->ForeColor = System::Drawing::Color::Black;
}

I'm not sure what you are targeting, but you could of course search the textbox's current text for something in your handler, and then make changes to the text color accordingly.

mitrmkar 1,056 Posting Virtuoso

I'll re-install it with MSDN and see if it does help at all.

It probably will, you can invoke the Help by pressing F1 whilst in the code editor, the help system then looks up the documentation on the currently 'focused' word in your code.

mitrmkar 1,056 Posting Virtuoso

You need to do customized drawing for the Textbox. It can be difficult/complex to implement, depending on what you want to do. Anyhow, if you are interested, then look e.g. into
http://msdn2.microsoft.com/en-us/magazine/cc164019.aspx

mitrmkar 1,056 Posting Virtuoso

Hello!!
I am using Keil Compiler C166. I want to know how much ROM, RAM has been utilized by the code.
Can someone help me for this?

Look into the produced listing file (.LST).

mitrmkar 1,056 Posting Virtuoso

Allright, now it compiles, but I asked my friend to run it and now he gets this message:

applicatin failed to start because its side by side configuration is incorrect. please see the application event log for more detail

What does that mean?

I'm not sure, but the event viewer (eventvwr.exe) Application log may contain more detailed information about the error (i.e. even the name(s) of the missing file(s), if any). So you may want to look into there.

It may be that installing the VS 2005 runtime components onto the offending machine solves this problem. These components are available at
http://www.microsoft.com/downloads/details.aspx?familyid=32bc1bee-a3f9-4c13-9c99-220b62a191ee&displaylang=en

mitrmkar 1,056 Posting Virtuoso

Use the < operator instead of <= in both of your for loops, i.e.

for(i= 0; i < Sensor.size(); i++) {
	  for (j=0; j < Observations.size(); j++) {
  }
mitrmkar 1,056 Posting Virtuoso

Um, what exactly does compiling it as release change

The release version of your program requires a different set of .dlls to be present on the target system.
What linker errors are you receiving?

mitrmkar 1,056 Posting Virtuoso

Well, how do I know and access the paremetters of this command?

In general, look into the documentation of each of the functions that you are to use. If you installed MSDN along with VC 6, you already have a lots of documentation on your computer.
On internet, there are available tutorials/references on the language itself, if you happen to need one.

mitrmkar 1,056 Posting Virtuoso

If you are referring to the MFC's CMap, then start by looking in here
http://msdn2.microsoft.com/en-us/library/s897094z(VS.80).aspx
and perhaps here too
http://www.codeproject.com/KB/architecture/cmap_howto.aspx

mitrmkar 1,056 Posting Virtuoso

Maybe the following clarifies it

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
	char** p = NULL;
	const int numStrings = 2;
	char string[21];

	p = (char**)malloc(sizeof(char **) * numStrings);

	for(int nn = 0; nn < numStrings; ++ nn)
	{
		sprintf(string, "string %d\0", nn);
		p[nn] = (char*) malloc(strlen(string) + 1);
		strcpy(p[nn], string);
	}

	for(nn = 0; nn < numStrings; ++ nn)
	{
		printf("string %d = [%s]\n", nn, p[nn]);
                // free the memory as we go
		free(p[nn]);
	}
        // finally free memory pointed to by p
	free(p);
 	return 0;
}
mitrmkar 1,056 Posting Virtuoso

Could you post the code that wraps CreateProcess?

mitrmkar 1,056 Posting Virtuoso

I'm not sure whether I fully understood your question, but
consider the following program

#include <iostream>
using namespace std;
int main(int argc, char * argv[])
{
	if(2 == argc)
	{
		cout << "received: (" << argv[1] << ")" << endl;
	}

	return 0;
}

Let's say that the program executable is named arg1.exe, and you invoke it as follows:

arg1.exe "this string contains spaces"

you should see the following output:

received: (this string contains spaces)

mitrmkar 1,056 Posting Virtuoso

A short tutorial on pointers
http://www.cplusplus.com/doc/tutorial/pointers.html
Also pointers to void (i.e. void *) are discussed there ...

mitrmkar 1,056 Posting Virtuoso

Try valgrind
http://valgrind.org/info/

As a general note, you should add error checking to your code. As of now, there is none.

mitrmkar 1,056 Posting Virtuoso

Is it not possible to find the next occurence of a character and then find("]") wich comes after the string stringToFind ?

The find() function can be told where to start the search from, see below

string Line = "a4545l5l[12] 1Number2[51] 2Number[1]";
string stringToFind = "1Number2[";

string::size_type startPos = Line.find(stringToFind);
startPos += stringToFind.length();

string::size_type endPos = Line.find("]", startPos);

string Number = Line.substr(startPos, endPos - startPos);

cout << Number;

Remember that find() returns std::string::npos, if there is no match, so handle that case also in your code.

mitrmkar 1,056 Posting Virtuoso

The bahaviour would perhaps be more understandable if written like

int main()
{
   using namespace std;
   for (int i = 0; i < 3; i++)
   {
       for (int j = 0; j < 3; j++)
       {
           cout << i << " " << j << endl;
       }
    }
   return 0;
}
mitrmkar 1,056 Posting Virtuoso

Appears as if you were not having the corresponding .cpp included in scope of compile/link, i.e. the one in which you've implemented e.g. AppointmentBook::AppointmentBook() ...

mitrmkar 1,056 Posting Virtuoso

You need to reset the file's error state flags, see e.g.
http://www.cplusplus.com/reference/iostream/ios/clear.html

[B]     file.clear();[/B]
     file.seekg(ios::beg);
     while( file >> word)
         cout << word;
mitrmkar 1,056 Posting Virtuoso

Try using
#include <iostream>
instead of
#include <iostream.h>
iostream.h is a deprecated header, hence you receive the warning.