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

Welcome to DaniWeb -- and don't be shy about joining in on any of the discussions. New blood (members) is always welcome.

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

I don't understand why you have done b++

if he didn't the program would crash because there is no such value as a[-1]

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

>>am currently reading a mfc book (professional mfc with visual c++ 6

Top reading that book! The compiler is old, non-c++ compliant, and the version of MFC that it teaches is also obsolete. If you want to learn MFC then get a book that teaches it from VC++ 2010 compiler.

If you want to do professional programming then you will want to learn a lot of languages, but learn C and C++ very well (become an expert in those languages). After that I'd learn C# and C++/CLI both are .NET languages. MFC would be my last choice today because C# and Windows Forms are modern and easier to learn.

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

>>Give names of some languages that use negative array index

A couple centuries ago I worked with a version of HP BASIC that would let you use negative index values without doing any of the tricks as previously posted in this thread. When the array is declared you specified both the upper and lower range of index values, for example if you wanted an array with index values between -10 and +10 you would declare it as DIM MyArray[-10,10] as Int or something like that.

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

Thanks for the reply.

I'm making a Win32 console application, making it an empty project, and adding a *.cpp file into source files folder.

About declaring main functions, I think that there is probably my mistake. In my second made *.cpp file I also make a main function and should that be a problem? Does when I run the file it reads both *.cpp files?

I tried making a new solution, then making one project, with *.cpp file, when running everything is OK. Then adding a new project to the same solution, also including a *.cpp blank file, writting simple code for displaying the value of an integer, but it executes the first *.cpp file it doesn't even load the second project.

Don't know where the problem might be. I probably didn't get your idea with the multiple projects.

Learn to use the right mouse button to acccess additional popup menus. In the Solution Exploror window, select the project name you want to run, press the right mouse button, and you will get several options for that project. Don't be afraid to explore them out to find out for yourself what they do.

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

VC++ 2010 and earlier versions will create assembly listings of your c and c++ programs. You have the option of having it include the op codes too.

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

If you have to search the entire hard drive then the program will miss some of them because it will take a lot more than than 1 minute to do the searches.

Look up (e.g. google) low FindFirstFile() and FindNextFile() work and you will find out how you can use them in your program.

Because the above will be too slow for your purposes another option is to let MS-Windows notify your program when files change within a folder. Read this link to see if it will help you.

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

The entire win32 api is written in C language, not c++, hence there are few if any C++ tutorials. If you want strictly c++ then I'd suggest looking into wxWidets

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

I disagree. IMO it's better to open the file for read, close, then open for write. At least for beginners. But you should close the file before opening it a second time, and use the same FILE*.

Either way will work ok, but leaving the first file open and opening it again can cause big problems.

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

Since I don't have access to the Moderator's Reported Posts forum I'll just take your word for it.

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

I always enjoyed programming, especially the satisfaction of the many achievements working out problems. I only do things I like doing and leave the other tasks up to someone else because not only do I not like doing them but I'm woefully inept at the jobs. I didn't realize that I could be any good at programming until I was about 40 years old and discovered that programming wasn't all that difficult to do. And yes, here in USA, I niched out a very good living standards and old-age retirement benefits. I don't program professionally any more but I do still enjoy helping others when I can here at DaniWeb and PFO.

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

I was thinkng more of insertng links to other threads such as when reporting duplicates. I realize smilies
would not be appropriate here.

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

You can get a list of all the files/folders in a folder by first calling FindFirstFile() then call FindNextFile() until it returns no more files. Both functions returns a structure that contains the timestamp that your program will need to check. The problem is that your program may not be able to detect files that are newer than 1 minute, but you'll just have to run the program to find out.

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

Dani, will you someday change the editor in the Report Bad Post link to use the same advanced editor that is used in other places, so that we can see the "insert link" and smily faces buttons? I could probably insert the tags manually but never seem to remember how to do it.

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

First, its not good to open the same file twice. Use just one FILE* pointer and use it for both reading and writing. Call fseek() to move the FILE pointer back to the beginning if you need to but its not necessary to open the file again.

The only way to delete parts of a file is to completely rewrite it. Read the entire file into memory, make whatever changes you want in memory, then write the whole thing back out again. If the file is too large to fit in memory all at the same time then you can to the same thing by reading and writing a single line at a time, but using two different files (the original for reading and another temp file for writing). I know that sounds like quite a hassle but, as you have already discovered, its the only way to successfully change the data in text files that have random length records.

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

But that's like saying you can only use the tools that were available 2,000 years ago when Jesus walked the earth to do today's work. Assembly may be the father of all computer languages but sure isn't the best one, or even the most efficient one to use today.

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

Link here, a little old but I think its still relevent

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

Previously had:
3 rabbits
2 guinea pigs
3 cats
1 dog
5 goldfish
2 hamsters

Currently have:
2 dogs
2 cats

Wow i've had waaayy too many pets :p

That's not pets -- you had a zoo :)

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

Not possible in the way you described it. But what you can do is to give functions a text string name that is associated with a function pointer.

struct fns
{
   std::string name;
   int (*fn)(); // function pointer
};

Now you will make an array of the above structures. Then when you need to execute a specific function just search the array by text string name. You can do similar with remote processes. Process1 (P1) sends Process2 (P2) the name of the function to be executed and P2 searches the array for the desired function pointer.

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

Oh, so that means the code you posted is not the same as the code you are compiling. Next time please post current and correct code, not something you just contrived so that others don't try to solve non-existent problems.

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

In Numbers.cpp you failed to provide the class name in front of the function names on lines 12, 16, 21 and 25. See line 6 for the correct way to code those functions.

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

@ Diwakar Wagle..Many Thanks to you - i am indeed grateful.

Then please give them some rep and mark this thread closed.

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

There is nothing in limits.h that will help in this assignment. You will need to use the sizeof operator to obtain byte sizes of data.

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

The head node itself appears to be uninitialized, except for the next pointer. Try changing the insert() method so that if head == NULL its set to current instead of allocating another new node.

void BulletList::insert(int posx, int posy)
{
    node* current = new node;
   (*current).next = NULL;
    if(head==NULL)
    {
       head = current;        //Head ska väl egentligen inte fyllas, lös detta med arv?

        (*head).next = NULL;     //Överväg att head inte kan ha y och x
        std::cout<<"Head next har något att peka på\n";
        //current = new node;
        (*current).x = posx;
        (*current).y = posy;
        (*current).travled=0;
        std::cout<<"Head ska få något att peka på\n";
        (*current).next = NULL;
    }
    else
    {
        node* previous;
        previous = head;            //Sista kan max vara den som head.next pekare på om head är fylld
        while((*previous).next !=NULL)          //Hitta sista elemtnet(det går inte att komma åt det snabbt
            previous = (*previous).next;
        //current = new node;                     //Skapar en ny node
        (*current).x = posx;
        (*current).y = posy;
        (*current).travled = 0;
        (*current).next = NULL;
        (*previous).next = current;                //Sista elemnetet pekar på det nya, skulle inte behövas om while(previous != NULL
    }
}
Epicurus commented: Identifies the problem and provides a solution. Great stuff! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Ok, so show is the code you have written so far.

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

Here is one example of a splash screen written in c++. I have not tried it so you might need to tweak it a little for c++/cli programs.

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

Also once you are in the work force you will start learning other languages as the need arises. College is not the end of your learning experience, but only the beginning.

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

When I said pointers I also meant the items you have already coded. You can code them as either pointers or integers. In any event the array itself will have to be a pointer so that you can allocate it with new operator. For now don't worry about coping old data that has already been read. It will eventually get overwritten with new incoming data so copying old data is not really a problem. You just have to adjust the pointers (integers) to accommodate the array's new increased size.

At this point we really can't help you much more without seeing the code you have already written. There are just too many different ways to do it.

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

Projects can contain multiple *.cpp and *.c files, but only one of those files can contain either main() or WinMain() (depending on whether the project is a console or win32 project). If you are attempting to add multiple files each with their own main() then you are doing it wrong.

In that case, you want to create a blank solution, then add multiple projects to it. Remember, each project creates just one unique executable, library, or DLL. But you can have multiple projects in the same solution. When you want several unrelated programs then I find it just simpler to create separate projects for them. But one solution with multiple projects will work too.

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

You will want at least two functions -- the main startup code and a function named printf() (not the one from standard c library, but your own very simple version). As previously mentioned there are a variety of assembly languages, so pick one the the target computer you want to use. masm and tasm are commonly used assemblers for Intel and compatible processors. Then you will want to read a good intro to assembler book. The one I learned from was written by Peter Norton but most likely out of print now.

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

IMO that defeats the purpose of a circular array. But anyway, just make it a pointer and allocate new memory when needed, similar to what gerard mentioned previously. When the current pointer reaches the current maximum size then allocate a new array of larger size, copy the contents of the current array into the new array, then delete the current array. Not difficult to do once you understand the algorithm.

Once you get that part working then you will have to be concerned about reads from the circular array. You will have to have two temp pointers, one for reading and the other for writing. If the data is not read at least as fast as its written, then the array will eventually fill up and there will not be any more room for writing without overwriting existing data that has not been read. This situation can happen anywhere withing the array, not just at the extreme end of the array.

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

My son swears by newegg.com. When I need hardware I just ask my son to get it for me and newegg almost always has the least expensive prices. I don't know about ordering large quantities of IT equipment.

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

C, C++, php, java, C#, and SQL are probably the most important ones. A great deal will depend on the kind of programming you want to do.

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

It might be helpful if you posted the text of the assignment instead of trying to paraphrase it.

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

Expand the program to include customer billing and employee pay/data. Also mail customers reminders when their pets are due for shots etc (mine does that is why I mentioned it).

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

>>So, how do you grow a circular array?

You don't. The array itself never changes size. When the current pointer reaches the end of the array then just reset the current pointer back to the beginning of the array -- hence its name is "circular".

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

Of course you can do it with a drop down list -- just put the code in the selection event handler.

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

>>First off, this is my first c program and i am by no means a programmer so ignore me if i don't meet your standard and let those willing to show me how it is done respond.

What a rude first introduction and first impression! Guess I'll just stop reading your post right now. Old proverb -- if you can't take the heat then stay out of the kitchen.

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

Example of Form1.h (see the red lines for my code)

#pragma once
#include "Form2.h"
namespace MyProject {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
    private: System::Windows::Forms::Button^  button1;
    protected: 
Form2^ f2;
	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->SuspendLayout();
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(101, 119);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(75, 23);
            this->button1->TabIndex = 0;
            this->button1->Text = L"button1";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(282, 255);
            this->Controls->Add(this->button1);
            this->Name = L"Form1";
            this->Text = L"Form1";
            this->ResumeLayout(false);

        }
#pragma endregion
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 f2 = gcnew Form2;
                 f2->ShowDialog();
             }
    };
}
Merex commented: Wonderful! Really helpful member!! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is called CGI programs (see these links for details). Your C program is installed and run on the web server.

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

You have to create an object of type Form2 before calling ShowDialog() -- can't be done all in one statement like that.

...
// somewhere in protected section of Form1
Form2^ f2;

....
...
...
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
     f2 = gnew Form2;
     f2->ShowDialog();
 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I'm currently using Microsoft Visual C++ 2010 Express edition to create my application in, should I be using something else?

Depends on the application. C++/CLI, C#, or VB.NET may be better languages especially if there are lots of windows and other visual objects.

>>I'm currently using Microsoft Visual C++ 2010 Express edition to create my application in, should I be using something else?
This is very very basic questions. You need to either read some tutorials or a good intro to C++/CLI book. Learn the language before jumping right into your application program.

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

You will need two loops, one inside the other. The outer most loop counts the rows, then the innermost loop counts the number of starts to be printed on each row. The innermost loop will count from the 0 up to, and including the value of the outermost loop.

Your assignment I assume is to teach you how to write loops, so I'm not going the give you actual code. Instead, you take your best shot at programming and post your attempt along with specific questions.

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

One way is to call strstr() to see if the string contains " HELL " (notice the spaces within the quotes.

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

why even bother to translate it into assembly? Other than, of course, for the learning experience. Other than academic, there is no good reason to translate it.

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

Did you compiler your source code for debug? Did you link with debug version of OpenCV2.1? I don't know the answer to your problem, but that would be the first things to find out.

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

What operating system are you trying to run that compiler under? It won't run on Windows 7 without running it inside DosBox

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

When I was growing up on a farm we had about 25 cats, all of them lived in the barn and hay lofts. Needless to say, we had no mice.

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

>>I don't know how to debug my own code,

Well, you had better start learning. The first thing you need to do is to tell us what's wrong with the program? What does it do that it's not supposed to do, or vice versa.

The first thing I noticed is that you have declared functions within functions. For example main() starts on line 4, then add() starts on line 9 but before main() is finished. You can't do that. You have to finish one function before coding another function.