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

Here is a tutorial you can start out with. Hope it helps. BTW I've never used that so I will not be able to help you with it.

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

>>char *r = memcp(d,s,6);

do you mean to call memcpy()? There is rarely a reason to catch the return value of memcmp() because all it returns is the destination buffer pointer. It has no error checking.

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

If the text file contains many user names and passwords then you have to completly rewrite the entire file in order to change just one of their passwords.

Open the original file for reading
Open a new temp file for writing

For each line in the original file
   Read a line into memory
   if its the line for the user name you need to change then then the password in that string
   write the line out to the new temp file
end loop
close both files
delete the original file
rename temp file to the same name as the original

Another way to do that without using the temp file method described above is to read the entire file into a vector of strings, search the vector for the line that needs to be changed, then rewrite all the strings back out to the file.

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

You need to include <string> header file.

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

Here is an example where Form1 copies the text from Form2 after Form2 closes. In Form2.h I added a public method that return the String from its textBox1 text control. Similar technique can be used for all of the controls on Form2.

Form2.h

public:
        String^ GetTextBoxString() { return textBox1->Text; }

Form1.h This method is envoked when a button control is clicked.

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 Form2^ f2 = gcnew Form2;
                 this->Hide();
                 f2->ShowDialog();
                 this->textBox1->Text = f2->GetTextBoxString();
                 this->Show();
             }
    };
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not sure what your asking. You have Form1 that invokes Form2 and you want Form2 to return something to Form1?

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

>>If you can you should avoid the getters and setters and create a function that already does what the user would do by using the getters and setters

Huh??? Sounds like a contridiction. How do you avoid getters and setters by creating a function that uses them??

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

A DLL can not be used as a start application because it isn't an application. A DLL is nothing more than a collection of functions and classes that can be shared among multiple applications. A DLL itself can do nothing.

You can only set one of the projects in a solution as the Startup applicaiton. Only executable programs (with *.exe file extension) can be declared like that. (This is not the same thing as debugging a DLL).

This article explains VC++ 2010 Solutions in detail.

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

It's also not portable -- can only be compiled with Turbo C.

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

Wow!! Greate find :) Yes, size does matter, doesn't it.

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

Was there a question or comment? I think you should use more parentheses for clarity if ( (cached >= 0 && cached < 1000) || (cached < 0 && cached > -1000) )//

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

A lot of people will disagree with you. HappyGeek wouldn't be caught dead without Chrome (he has stated that on more than one occasion).

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

IMO the greatest advantage of getters and setters is that there is only one place in the entire program that accesses the class variable. If something has to be changed than you can change is in only one spot instead of hundres of places throught the program. Make the variables private to enforce that position even for trivial cases. Once you start writing larger and more complex programs you will learn to appreciate those get/set methods.

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

Thank you -- at least that is readable. :)

I see no reason for the use of variable cashed, at least not in the code you have posted. There are cases where it may be necessary to save the value of a vairable before changing it. So the validity of the two if statements may depend on the value of cashed and data_. It all depends on the rest of that function.

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

I don't use a laptop, so I can't help you with that. Suggest you start a new thread here to begin discussion of your problem.

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

>>Please see comments in code.

Impossible. The code you posted is just formatted too awful. And the code tags are wrong.

[code=cplusplus] // your code here

[/code]

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

>>Update: The professor in question has been reported and is now banned from taking any more classes.


hallelujah! :)

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

What browser are you using? try Google Chrome and see if that fixes the problem because its faster than IE. Don't know about FF because I have not used it for a couple years now.

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

>>Does that mean something's not right?
No, it means the code has been ported to both MS-Windows and *nix. If compiling on MS-Windows then define INCL_WINSOCK_API_PROTOTYPES somewhere before the code snippet you posted. Using preprocessor instructions like that is a common way to write portable programs that are compiled with different compilers and/or operating systems.

Use of the FAR macro would leave me to believe the code was written for some 16-bit segmented MS-DOS compiler. 32-bit compilers do not use FAR.

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

No. use POSIX sockets. The two are a lot alike so it shouldn't be all that difficutl to port from MS-Windows to *nix.

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

prinf() doesn't work in Windows Forms applications because there is no console window for the text.

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

First program:
line 18: fread() doesn't work very well with stdin because it doesn't terminate the input with the string null terminator. That's why everyone calls fgets().

Since you are writing a c++ program you can do away with fgets() and fread(), just use the functions in std::cin and std::string std::getline(newBuffer, std::cin); line 26: you can only call free() on pointers that have been allocated with malloc(). Since Buffer has not been allocated with malloc() the free() call on line 26 will fail. Your compiler should have complained about that, assuming you attempted to compile that code at all.

line 28: you are assuming that the find() on the previous line succeeded. What will that do if it failed? You need to add some error checking here.

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

>>Plus, I do not believe that the world will end on exactly 12/12/12

I agree -- did the world come to an end on 1/1/11? Noooo. Besides, someone in a tabloid last month claimed it will come to an end in Sep 2011. So you all better get your personal lives in order because you don't have much time left :)

jember commented: lol xD +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a complete explanation if you're really all that interested. Applies to 16-bit MS-DOS compilers. If you want to port a 16-bit program to 32-bit compiler than just define FAR to be empty

#ifdef FAR
#undef FAR
#endif
#define FAR

You will want to do the same with NEAR

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

You are reading the wrong tutotorial -- that was written for MAC, not MS-Windows. It's quite easy with VC++ 2010 Express or Code::Blocks, both compilers have start-up templates that generate appropriate code for you, then all you have to do is add your own code that you want to export from the DLLs.

Ditch that old, ancient Dev-C++ compiler that hasn't been updated in a couple centuries and get either of the above two mentioned compilers.

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

did you add the pdcurses library to the project? or usr a pargma to include them? such as #pragma message(lib,"pdcurses.lib") in one of your *.c files.

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

I didn't say floats and doubles were compiler depedent. I said long doubles were. Some compilers support long doubles as twice the size as doubles while other compilers such as vc++ 2010 (and earlier versions) treat them the same as doubles.

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

why is the sky blue? doubles have more precision than floats, and long doubles may or may not have more precision than doubles (compiler dependent).

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

Today i learn how to control your feelings when you are getting angry with someone.

That's great :) It will be something you can use throughtout your whole life.

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

Yes, why not?

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

That's correct -- no 32-bit compiler supports GBI graphics. You can only use it with turbo c compiler. If you are trying to run turbo c on Windows 7 then you have to install DoxBox first, then run the compiler from within that program.

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

If you look in logmsgs.h you will probably find that function defined there. You can not put executable code in header files because it results in the error message that you got. Put just the function prototype in the header file and the actual function in one of the *.cpp files.

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

or simplified like below. Note the function is unsafe, just like strcpy(), because it blindly copys the characters from one string to another without regard to whether the destination string is large enough to hold them all. A better solution to that problem is the same as strcpy_s() -- pass another parameter which is the size of the destination buffer.

void string_copy(char *p1,char *p2)
{
        while(*p2)
           *pt1++ = *p2++;
        *p1 = '\0'; // null terminate the string
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The thread is over 6 months old. Maybe the op has already solved the problem.

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

Put code guards in timers.h fixed the problem for me. Note the preprocessor directives at the top and bottom of the file. This prevents the preprocessor from parsing the file more than once in the same *.cpp file.

#ifndef _TIMERS_H
#define _TIMERS_H
#include "includes.h"


class servtime
{
public:
	int sec()
	{
		int sec;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		sec=timeinfo->tm_sec;
		return sec;
	}
	int mint()
	{
		int min;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		min=timeinfo->tm_min;
		return min;
	}
	int hour()
	{
		int hour;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		hour=timeinfo->tm_hour;
		return hour;
	}
	int day()
	{
		int day;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		day=timeinfo->tm_mday;
		return day;
	}
	int month()
	{
		const int MONTHS[]={1,2,3,4,5,6,7,8,9,10,11,12};
		int month;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		month=timeinfo->tm_mon;
		return MONTHS[month];
	}
	int years()
	{
		int year;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		year=timeinfo->tm_year;
		return (1900+year);
	}
};
#endif
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What are your answers? Instead of us just telling you the answers you should try to figure them out yourself, post the answers, and we'll grade your work or answer questions about what you don't understand.

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

step 3 will have to use floating point numbers because one integer divided by another integer will not produce any fractions.

fmod() returns the remainder after division, similar to mod operator % for integers. So fmod(1.1234,1.0) will return 0.1234

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

bitmap.Save() does not take std::string as its first parameter. Did you try bitmap.Save(dir_save.c_str(), &clsid); Here is how to convert char* to wchar_t*

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

You could make your program a little smarter and if the clipboard contains binary data (e.g. a file) read it that way. You really shouldn't put an entire file into the clipboard anyway.

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

>>We need to pass the logical drive letter before /Users and we need to pass the username in between /Users and /AppData.

Well, that is pretty trival thing to do. Just create a std::string

std::string path;
path = pch;
path += "Users\\";
path += username;
path += "\\AppData\\Local\\Microsoft\\Windows\\*.*";

int ff = _findfirst(path.c_str());
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You will first have to figure out what your widget needs to do then program it using very low-level GUI functions, on *nix using something like X11R6 or MS-Windows use win32 api graphics functions. This is not an easy task and not for the unexperienced. On MS-Windows it isn't as difficult as on *nix because you can write your own ActiveX control that contains all the code for the new widget. Using VC++ 2010 Pro you can create an ActiveX control is a matter of just a few clicks of the mouse, the compiler will generate all the startup code for you.

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

>>If not a third world war,t

There will never be another third world war -- USA has enough nuclear stuff to destroy the whole earch all by iteself without help from anyone else. A couple other countries could also do that -- such as China and Russia.

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

I installed and tried google chrome today. Yes, its faster than IE, but still ... speed isn't everything.

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

Why don't you just put both *.cpp files in the same *.so?

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

Here are a few links that you should browse.

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

At the bottom of my profile there are some links to the "Domains currently linking to this page". Where do you come up with all those links? Some are not valid links, another is Google's home page. Is there a way for you to verify those links once in awhile (say monthly or less often) and delete the ones that are not valid? Or give is the option to edit the list and remove invalid ones ourselves.

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

Functions should never ever be in header files -- only function prototypes. The reason is if you have that header file in two or more *.cpp files then attempt to link those *.cpp files together you will get duplicate declaration errors.

Here is how to correct that problem
count.h

extern int count(int );

main.cpp. Notice how I made a few changes to your program

// Always put the include headers at
// the top of the program, like this:
#include <iostream>
#include "count.h"
using namespace std;

int count (int x) {
	x = x + 1;
	return x;
}

int main () 
{

   int num;
   num = 24;
   std::cout << num << std::endl;
   num = count (num); // you have to capture the return value of count()
   std::cout << num << std::endl;
   std::cin.get();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 147: why are you using variable limit in that loop? The value of limit could be any random number because its used in the previous loop as file input.

>>Ok then could you give me some help as to how I can correct those errors?
Make the two functions return a value. Or -- if no value is to be returned then declare the functions to return void.

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

If you hury up you can correect the code tags.

[code=cplusplus]

Notice no spaces and its cplusplus not c++


Are you talking about converting UNICODE wchar_t* to char*? Here is a thread that shows one way to do it.