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

its not working because you need to use a lot more counters. using only one counter what do you do when the characters in the string are in random order?

<< *dest = counter + '0';
That will not work when the value of counter is greater than 9 because 10 + '0' is 10 + 48 = 58, or the ascii value for a colon (see an ascii chart) But it will be ok if your assignment limits the number of allowed characters to less than 10.

>> source++;
move that line down just below the end of the if statement because source needs to be incremented at each iteration of the while loop.

>> counter=0;
move that line up under the else statemnet. Only want to zero it out then the letter changes.

Aia commented: Very good +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

first I would create an array of 126 integers because there are at most 126 possible characters on the standard keyboard. Initialize all ints to 0. Then loop through the array and use each character as an intex into the array so that its element can be incremented. When done, only the array elements whose value is greater than zero were in the original string.

For example

int array[126] = {0};
//
// increment an array element
++array['a'];

// loop through the original string
int i;
char str[] = "aabbbbcccdddd";
for(i = 0; str[i]  != NULL; i++)
   ++array[str[i]);
// now you should be able to figure out the rest
// of the assignment
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Thanks joe it works fine right now.

So I guess you have solved all the problems. Great! :)

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

If you are compiling a.cpp what makes you think a.h is not being included?

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

what compiler are you using?

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

It would help if you would learn how to use tabs and spaces correctly so that your program is easier to read/understand. As it is few people, if anyone at all, will bother to read it. And what are lines 9 through 11 supposed to do? Must be a copy/paste error.

Salem commented: It's endemic isn't it - salem +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>If the world stopped having sex all together, what do you think would happen?<

That's pretty hypothetical, but it would probably increase the amount of conflicts and even wars. As those horny guys in charge of militaries around the world got more sexually frustrated than they already are, they'd probably phony up more reasons to fight each other.

That's the first sane statement made in that entire web site. Pretty amusing anyway.

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

void values(int a[4]); That is a function prototype that tells you and the compiler that function values will have one argument and the argument is an array of 4 integers. values(x[4]); (cannot convert int to int* and type mismatch in parameter 'a' in call to'value(int *)' Here you are not passing an array of 4 integers -- you are only passing one integer that happens to be the 5th member of the array. Because array x only has 4 elements (the elements of array x are 0, 1, 2, and 3) you are passing an invalid element number.

The way to correct the problem is to pass the whole array, like this: values(x);

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

I think writing this heavily object-orientated aspect, in assembly, would probably take the rest of my lifetime...

:eek: No, not the whole blasted program !

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

>>The nature of this application is that it needs to be extremely fast. So shaving nanoseconds is important to a degree.
If speed is that important then don't use c++, but use C instead. And code in assembly when needed to optimize some time-consuming algorithms.

I don't think virtuals make a program slower, just a little larger. The way I understand them virtuals are little more than function pointers and calling a function through a function pointer is only a couple clock ticks slower than calling the same function directly.

>>Also a very important thing which mars the performance of virtual functions is that they can't be inlined
Although that is a true statement, large functions are never inlined anyway unless using a very stupid compiler.

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

According to Wikipedia it was originally brought to England from Germany. You guys just twisted it around a lot before it got to there it is today.

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

lol i love the english language its so random :)

Yes, I do too. Glad you Brits invented it .:)

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

>>There is a problem in the execution of cl.e file
No, there is nothing wrong with the compiler. Your program is really quite a mess. I tried compiling it with VC++ 2005 Express and got trillions of errors.

Correct the problems one error message at a time. Recompile your program after fixing an error and then fix the next error.

One of the biggest problems I think you will have is correcting unmatched curly braces. You start out by defining class hospital but in the middle you start declaring class reception. Although this isn't illigal its not a good thing to do.

And for goodness sake don't be so skimpy with spaces and blank lines! Put a few blank lines between class declarations to make your program easier to read.

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

Americans tend to pronounce is as "r - out - er", the same way as they pronounce route "r - out" Brits and a few other nationalities tend to pronounce is as "rooter" as we pronounce "route" as root.

Simple, eh?

Brits speak funny anyway. Especially humerous is the way they pronounce school and schedule. Both words start with sch but they pronounce them differently. Maybe its a carry-over from Shakespeare days.

root is not a verb it is a noun,.

root is both a noun and a verb. See dictionary entry.

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

modf() will help you split a floating point number into its integer and fractional parts. see man pages for more details8

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

you need some braces around that loop

// copy the file into the buffer.
            while( 0 != read_one_float( &tmp_float, file_pointer ) )
            {
                buffer[i] = tmp_float ;
                printf("\n\tNumber of entries read : %d, value: %f\n\n", i , buffer[i]);
                ++i;
            }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> Now how do I find the address where in the memory my object is created?
The address stored in the this pointer is the address of the object. Here is an example that illustrates this. Notice that the value displayed in lines 8 and 18 are the same address.

#include <iostream>

using namespace std;
class A
{
public:
	A() {x = 0;}
	int getX() {return this->x;}
	void printThis()
	{
		cout << this << endl;
	}
protected:
	int x;
};

int main()
{
	A a;
	a.printThis();
	cout << "&a = " << &a << endl;
	cin.ignore();

	return 0;
}

>>But damn this basic concept has slipped off my mind when I coded
Don't worry, it will come in time. Practice makes Perfect is one of the golden rules. We were all beginners at some time.

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

some of those registered users are really spammers whose posts have been deleted. I don't know if banned users are counted in that number or not. Some people register for the sole purpose of posting spam and have no intention of participating in DaniWeb community.

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

I visited conqueryourniche.com the other day, and they have this great idea to make people want to post! It works like this: everytime you post, you get points. For every five points or so, they'll display your ad for free! But there're too many members there that the only chance your ad is ever going to be read at all is if you're a platinum member.

Nice concept, though!

If there are so many members that nobody will see the ads then its not such a great idea afterall.

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

Thank for your reply, that is right. But I would like ask you that Is there any software can convert this program to 32bit

you will have to port it yourself manually. I suppose you might be able to write a few wrapper functions for the 16-bit functions, such as write your own int86(), inp(), outp() etc. If you search google you might already find them, I don't know.

Yes. A compiler.

:mrgreen: :mrgreen:

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

>> if ( (file_pointer = fopen(filename, "rb")) == NULL )

The program should be open for reading a text file not a binary file -- "rt" not "rb". for( j = i; j >= 0; j-- ) j should start at (i-1) because the ith row at that point does not contain a valid number.
or just loop the opposite direction for( j = 0; j < i; j++ )

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

argv[0] parameter in main contains that info.

int main(int argc, char *argv[])
{
   printf("%s\n", argv[0]);
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You didn't say but I suspect that may be an old 16-bit program that is accessing ports directly. If that is correct then you will have to rewrite the program using win32 api communications functions. I think you will also find some examples in those links.

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

>>t of all, is it called a This pointer or a This operator?

this is a pointer. An operator is something else.

c;ass pbkects are private by default. If you want to make them public then you need to specify it.

functions need to have a return type, c++ does not permit default return types.

class A
{
private:
    int x;
public:
    int fn() { return this->x; }
};

>> am also recieving a warning like 'x' is assigned a value that is never used
Because you have to initialize variables to something (usually 0) before they can be used. If not initialized they will just contain some random value. Class variables are normally initialized in the class constructor, like this:

class A
{
private:
    int x;
public:
    A() {x = 0;}
    int fn() { return this->x; }
};

>> I am trying to find out the address of the memory which is held by the THIS pointer
The actual address is not important to most programmers, but it is the address of the class's instance. In the main() function you posted it would be the address of object a.

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

Dani you are right :) , I apparently did accidentally switch modes.

>>Firstly, why didn't you just upload the file as a JPG?
I thought it might be too big.

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

That worked -- thanks for the link and information. :)

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

Attached is a screen shot. unzip and its a *.jpg file to retain colors.

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

I don't like the new format of the threads -- a brief list of thread links at the top of each thread (I don't know what they are called). I find them annoying and almost useless, especially in Geeks Lounge where some threads have hundreds of posts. And it looks silly in threads with only the initial starter post.

It also makes huge threads such as this one very very slow to load.

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

Has anyone successfully installed Acrobat Reader? It downloads ok, uncompresses, then gives the error message "The Temp folder is on a drive that is full or is inaccessible. ...". I used command prompt to display the values of all environment variables and the TEMP is in d:\users\<full path here>.

Anyone know a solution to this problem?

Thanks

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

Iowa is a state in the west. (of the US).

Its actually in the mid-west -- that's where I was born and raised, just a few miles North of Des Moines. Iowa is a great state to be from -- a loooooooooong ways from :mrgreen:

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

Select Project --> Properties
expand Configuration Properties
expand Linker
select General category
add path(s) to the libraries in "Additional Libray Directories"
click Input category under Linker
add library names in "Additional Dependencies"

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

what are the compiler errors?

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

know its just shorthand but the theory is the same

And what theory would that be? How does your code snippet help the OP write a substr() function ?

And why respond to a year-old thread?

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

I'm so sorry for asking but where should I insert or save C++.
I'm skilled in html css and javascript but I don't get this.

Your compiler will normally create an executable file in the same directory as the source code, or possibly a sub-directory. Unlike html and java to run your program you don't have to save it any specific place, just execute it wherever your compiler put it.

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

I don't have a clue what question you are asking.

function ch_in_string() -- there's a lot easier way to do that. std::string has a find method

bool ch_in_string(char ch, string s)
{
    return s.find(ch) == string::npos) ? true : false;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yea it has only its not constantly popping up for stupid little things it only really pops up when you want to install a program that has to change settings or that has permission to wake up/unlock my computer for example my alarm clock program does this.

Plus it was mainly the other things that i was talking about like the license agreement and microsoft making you do things their way all the time.

Dani said in another thread how to disable those annoying system popups. I disabled them and no longer have that problem.

I upgraded to Vista Home Premium a couple weeks ago and really like it. I don't do web programming so the ultimate edition is a lot more than what I want or ever use, and costs about twice the edition I bought. Did I need it? No. But its a nice os anyway, and comes with a few really nice games and new support for gadgets. I have not noticed any security problems, maybe because I always run virus scanner. Got a fee new one last week from Avalst. It seems to work ok -- scans email as well as browser communications and has a firewall.

I have found that some of the games I played in XP doesn't work in Vista. I'm glad installed Vista to duel boot instead of completly replace XP.

For businesses, I don't think Vista isn't worth the bother to upgrade, at least not at this time …

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

>>I've sedn how they get it to work using an array, but I can do it that way...Thanks

do you mean you are not allowed to use arrays or you don't know how to use arrays ?

Where does main() start? I see some exceutable code that is not inside any function. Looks like you forgot to add the curly-braces for main() beginning on line 16.

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

depends on what you want them for. do you need integers? or will just one bit do each element?

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

Yes, vampires are undead. The term "undead" was coined by Bram Stoker in his original book Dracula. Wikipedia has a large list of what is normally considered undead things. Undead creatures are considered evil -- I'm not evil so I wouldn't be any undead thing.

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

That's 524 meg only for the allocation of the first array. Then your program allocates 134,217,728 more arrays of 3 integers each, or another 1,610,612,736 bytes, for total of 2,147,483,648 (2,097,152 meg). Your computer does not have that much free ram.

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

512 * 512 * 512 * 4 = 536,870,912, or about 524 meg. Does your computer have that much RAM?

Check the return value of malloc() -- it will return NULL is not enough memory to allocate.

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

>>error C2601: 'word' : local function definitions are illegal

That means you tried to put function word() inside function main(). You have to finish one function before you can start another one.

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

>>error C2082: redefinition of formal parameter 'countword'

you have named a local variable the same name as a parameter -- that's a no-no. Use a different variable name.

Also look at lines 31 and 39 -- they are incorrect (extraneous 'd' at the end after the last '+').

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

What are your question(s) ? We are not going to do you assignment for you but will gladly try to answer your questions. Do the assignment one small step at a time. For example, start out with the first requirement read in a line of text Is it supposed to read from the keyboard or a data file? If you use getline() function then the syntax will be pretty much the same whether reading from a file or the keyboard. So get that part going correctly before attempting to write any more of the program.

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

difference in days between two dates is very easy to calculate.
1. get time_t for first date. If this is not today's date, then fill out a struct tm with day, month-1, year-1900 -- make all other structure members 0, then pass your struct tm object to mktime(), which will convert it to time_t.
2. get time_t for second date
3. subtract them -- this is difference between two dates in seconds
4. there are 24 * 60 * 60 seconds in one day. So take the result of step 3 above and divide by the number of seconds in one day.
5. finished.

#include <iostream.h>
#include <cdate.h>

1. iostream.h is very old and obsolete. current version does not have .h file extension. If you are using an acient compiler such as Turbo C++ then this is ok because your compiler probably does not support the new file naming convention.

2. cdate.h -- there is no such file. use either date.h or cdate (no file extension). This is how it might appear for modern compilers.

#include <iostream>
#include <cdate>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

one way is to use sprintf() to convert the int to a char string then print the string in reverse order.

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

what did you try? I think you have to first run the .config program which will configure the source to your computer. Then you run the make utility which will compile and install the libraries. This is the standard way that *nix source files are distributed. Some of these tasks require root permissions, so you may have to log in as root before attempting to run the make install utilities.

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

you are a beginner and your instructor gave you an advanced assignment like that :eek:

you will first have to build a linked list of names. After entering a name from the keyboard search that linked list for it.

If you do not know anything at all about c/c++ language or about linked lists you have a couple choices
(1) drop that class and sign up for an introduction to c or c++ class so that you can learn things that are suited to your current level of understanding.
(2) be prepared to do a lot of reading/studying about linked lists and console keyboard input. Your text book should cover all these topics.
(3) read through some of the stickies at the top of this board. There is a wealth of information for beginners as well as more advanced students.

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

dev c++ compiler does not support any of the functions in graphics.h. You need more than just a .h file -- you will also need a *.lib library file which dev c++ does not support. So even if you get your program to compile it will not link due to lack of libraries.

If you really want to use functions in graphics.h then you have a couple options: (1) use old version of Turbo C/C++ or (2) Upgrade to newest version of Turbo C (I don't know if that version supports graphics.h or not, I doubt it because I think Borland made a 32-bit compiler out of it and graphic.h was for 16-bit MS-DOS operating system)

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

graphics.h is a Borland-specific header file and not supported by any other compiler. When you write Windows programs you must use win32 api graphics functions, which are completly different than those you learned with graphics.h.