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

popcorn. But in a few minutes I'm going to make some more chicken creole soup, almost, but not quite, like this one

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

That really sucks cannel water. I don't know the last thing about web programming, but isn't it a DaniWeb problem? Or does the advertisers control the content of their ads on DaniWeb?

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

>>After all, the singularity that was at the origin of the big bang was so small it couldn't be measured.

How do you know that?? Did you see it (of course since it can't be measured then you probably didn't) ? Or is it just a guess?

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

Well, there are lots of places in Form2.h to put it, just make it public

public ref class Form2 : public System::Windows::Forms::Form
	{
	public:
		Form2(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}
        Rectangle r;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You might have to enable Expert settings. Go to Tools --> Settings, then check Expert settings. This has got to be one of the dumbest things Microsoft has ever done in their compilers.

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

After working with your original code that you posted I see you have a lot of problems keeping the counters i, j and k straight. Since you've had some time now to sort things out I'll post one solution. This code has one flaw -- white space at the beginning of the string will cause a minor problem.

#include <iostream>

int main()
{
    int i, j, k;
    char line[]="This is a test";
    char temp[5][5] = {0};
    for(i=j=k=0; line[k] != 0; j++)
    {
        if( isspace(line[k]) )
        {
            // skip all white spaces
            while( isspace(line[k]) )
            {
                k++;
            }
            i++; // increment line counter
            j = 0; // reset word counter
         }
        temp[i][j]=line[k++];
    }
    for(j = 0; j <= i; j++)
        std::cout<<temp[j] << '\n';
    std::cin.get();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

LPSTR is just a MS-Windows #define for char*.

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

The code is incorrect and the compiler will puke out errors at you. All parameters must be passed by reference. method(&a, &b, &c);

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

The rest of those two header files were generated by VC++ 2010. I posted all the code that I changed, except that you need to include Form2.h at the beginning of Form1.h

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

If I declare temp[5][5]=0 in the beginning and then initialise with strings later on, which there still be junk in the variable or will the characters not being occupied by the string continue to be null?

The characters that are not changed will still contain 0.

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

>>why not just assign memory location to p ?

Because the intent of the exercise is to show you how to make a duplicate copy of the original.

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

Here is an example of how to write a structure

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

The first step is to create a structure or class for the record. After that you can determine the file format. Finally, write each of the functions that add, insert, modify and delete records. Write and test these just one function at a time so that you don't get overwhelmed with the complexity of the program.

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

It's very similar to int ** -- a pointer to a pointer. That allows a function to change a pointer declared in the calling function. For example: linked list. When the pointer to the head of a linked list is declared in main() the pointer has to be passed by reference to a function that is going to insert a new node either at the head of the linked list or somewhere else within it.

struct link
{
   struct link *next;
   int x;
};

struct link* Insert(struct link*& head)
{
   struct link* newnode = new struct link;
   head = link; // add a new node to the head of the list
}

int main()
{
   struct link* head = 0;
   Insert(head);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

SetBouds() will move the window to the x and y coordinates you specify.

There is probably more than one way to do it, but this is how I solved the problem.

1. In Form2 add a public data member of type Rectangle, e.g. Rectangle r; 2. In Form1, in the OnButtonClick event handler

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 Form2^ f2 = gcnew Form2;
                 f2->r = ClientRectangle; // set the Rectangle object in Form2
                 this->Hide();
                 f2->ShowDialog();
                 this->textBox1->Text = f2->GetTextBoxString();
                 this->Show();
             }

3. In Form2,

private: System::Void Form2_Load(System::Object^  sender, System::EventArgs^  e) {

                 SetBounds(r.Right+1,r.Top,r.Height,r.Width);
             }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Check for buffer overruns and writing beyond the array bounds, which most likely will trash memory. This can be a tough job in large programs, so I'd start by commenting out large blocks of code until the problem disappears so that you can narrow down the problem.

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

>>Is there a solution to this?

Yes, use a loop. Your question is too vague to be of much more help.

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

If you declare temp like below then you won't have to worry about null terminating the strings because the compiler will flood all the bytes of temp with 0. char temp[5][5] = {0};

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

He meant that each string needs to have a null byte -- that's just the way C strings work. All the functions in string.h expect strings to be null terminated. If they are not, then they are just character arrays, not considered strings. So in your declaration of temp you have to make room for the charcters you want to put in the strings plus one more for the null terminating character.

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

I don't know what @ does.

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

NULL is used for pointers -- many compilers define NULL as (void *)0, which is not the same as 0.

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

0 and '\0' are identical and can be used interchangealy, which one you use is only a matter of programming style.

jonsca commented: Thanks. +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what is it that you want to do with strings? There's possibly an equivalent in c++.

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

"@" is not a command in any version of MS-DOS or MS-Windows. In the cmd prompt type Help <Enter> and you will get a list of all valid commands.

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

Put all that code in a *.bat file then call it from your c program, or just write the c program to do it by calling functions FindFirstFile() and FindNextFile(), then call delete() to remove the files.

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

macro is not a function -- its just a simple substitution for actual code. Whether it does what you are asking or not I have not the slightest clue.

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

tux4life said his version worked exactly like the original -- and core dump or seg violation is what the original does too :)

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

I have not read your code, but that error tells you that you did not code a function named draw(). You may have prototyped it, but you didn't actually code it.

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

Note that if you are using precompiled header stdafx.h must be the very first include file in the *.cpp file. If you are not using precompiled headers then it won't matter one way or the other where it is, and you could even delete it altogether if there is nothing useful in it.

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

Welcome to DaniWeb. I too retired from computer programming about 4 years ago because I was just getting too old to put up with all the stress that is involved. Let the younger people do it :)

We need experienced coders around here to help younger people with their problems,so feel free to answer all the threads you feel you are qualified to give your expert advice. Actually that's the reason I have such a high post count because I've spent some time to do just that.

AndreRet commented: Bragger! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Somewhat at odds with Ancient Dragon: I think that coding standards are useful prior to peer review,

I did not say code standards are not useful. Just the opposite. You can't have a peer review without them. My objection was for a tool that tris to enforce someone's coding standard on the world.

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

>>I'm guessing the array length of 255 is just an arbitrary length that you need to declare?

Yes -- make it whatever size you want.

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

Coding standards??? According to who's standards? My standards and your standards could be quite different, so I doubt there is any tool that can or could do a very good job of it. In a group of coders larger than 1 person that's what peer review does -- each coder review and analyzes the code written by the other coders to determine if the code meets company coding standards, whatever that is.

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

It doesn't. And you can't.

>>create an application in real mode that uses the flags to store the results of calculations and other stuff.
As I said before, that is a mis-use of the flags. Even if you could change them they won't stay that way very long because the flags are changed when certain operations are performed. The only flag I can think of that you can change yourself is the direction flag using cli instruction.

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

It's just a simple assignment

int competitorsArray[255] = {0};

competitorsArray[competitorCounter] = finalScore;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Lets assume all you need are 8 or fewer flags which can be store in one byte of data

flags db 0 ; allocate memory for the 8 flags

; set the 2d bit 
mov al,flags
or al,00000010h
mov flags,al
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think you are trying to make this more difficult than it really is. If you enter the psi for all 4 tires then all you have to do is subtract the psi of the two front tires to see if the result is less than 3, then do the same with the two back tires. This is a math problem that any 8 year old should be able to do.

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

>>I want to insert a variable finalScore into an array competitorsArray[competitorCounter]

Depends on what you mean by "insert". If you have an array that already contains numbers and you want to insert another one in the middle of the array without destroying the number that is already there then you will have to move all the numbers from the insertion point to open up an empty spot for the new number. That's just a simple loop to copy each number to its next higher index in the array. Start at the end of the array and work backwards until you reach the insertion point.

As for your second question -- c and c++ use floating points which have lots of digits after the decimal point. It's not possible using floats to restrict them to just one decimal digit. One way to solve that problem is to convert the number to an int then compare the integers. Example: int score = (int)(judgesScore * 10); Then compare score between 0 and 6.

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

You don't want to screw around with eflags like that -- you are misusing that flag. What you want to do is declare a variable to hold all the bit-mapped flags then you can set and clear the individual bits to your heart's content.

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

The function you are calling is UNICODE function. LPWSTR is a pointer to a unicode string, not an ascii string. You need to declare the string like this: wchar_t ConvertTime[9]; , or if you want to compile the program as either ascii or unicode then use the macro TCHAR: TCHAR ConvertTime[9]; and include <tchar.h> header file.

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

You may have been using vb6 but I will guarentee on my deathbed that you are not compiling c++ code with it. Maybe you mean VC++ 6.0??? Those two are not the same.

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

What is the significance of '\0'? That byte may appear in binary files hundreds or thousands of times, but will rarely, if ever, appear in text files.

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

What is that loop beginning on line 20 trying to accomplish? Read a file one byte at a time until EOF? ifstream.read() will return NULL when EOF is reached, so all you need to do is this:

char byt; // no need for a pointer here
while( inFileDrs.read(&byt, 1) )
{

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

In this case simply replacing the hyphens with spaces will not do it. For example 5-9 means 5, 6, 7, 8 and 9. Assuming that is the case, the code in lines 22-33 won't work. You need to extract the two numbers in the string "5-9" then create a loop that processes all the numbers between (and including) those two.

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

It meant to use the ShowDialog() method of a specific Form, as in the example I posted. Try it before complaining.

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

post the code you compiled.

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

If you are using VB6 then you are using the wrong compiler. VB6 can not compile c or c++ code.

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

That's wrong.

Form2^ fm = gcnew Form2;
fm->ShowDialog();
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are just kidding yourself if you think you can start with nothing and get a Ph.D. in two years. Good luck with that, but your goal is not reasonable. In USA a bachelors degree takes an average of 4 years (some very bright people can do it in one year), a Master's degree takes another year or so, and Ph.D. varies due to the theses that is required, and a theses is about the size of a large novel and requires you to do original research.