Narue 5,707 Bad Cop Team Colleague

If the object is myAC and the interface consists of turnOn and turnOff then there are only two things you can do with an existing object: call turnOn and call turnOff. The syntax to call a method of an object is a simple dot hierarchy <object>.<method>(<arguments>). Because turnOn and turnOff don't take arguments, you can leave the list empty and replacing object with myAC and method with turnOn, you get this:

myAC.turnOn();
Narue 5,707 Bad Cop Team Colleague
<a href="link" onMouseOver="document.image.src='on.gif'" onMouseOut="document.image.src='off.gif'">
  <img src="off.gif" name="image">
</a>

It's pretty simple really, onMouseOver and onMouseOut are events that are triggered when the obvious happens: the mouse enters or leaves the image boundary. document is the current HTML file, image is the name of the image we're working with, and src is the value of the image. Assigning to document.image.src changes the image, and we only assign to it during an event. Notice in the second line that the name of the image is set and the original src is off.gif.

Narue 5,707 Bad Cop Team Colleague

Let's look more closely at this:

list.count=0;
moreData=getNext(list,0,pos);

Notice how you set list.count to 0 and that the fromWhere argument is 0. Then in getNext:

if(fromWhere==0)
{
  if(list.count==0)
    success=false;

Both fromWhere and list.count are 0. Now back to printList:

while(moreData==true) 
{
  list.count++;

moreData is not true because you set list.count and fromWhere to 0. So the loop is skipped and the list is not printed.

Narue 5,707 Bad Cop Team Colleague

>Since my request was simple
"Tell me everything I need to know about this broad subject" is not simple.

>I would think the reply would be simple.
The reply was simple. :)

>a simple here's were you find the api's to create a new thread or create a database connection.
Let's see:

$ man -k thread

then

$ man -k socket

followed closely by a google search for "unix odbc".

Too simple? I thought so, that's why I ran you down about it. The first thing that a new Linux user learns is how to ask the man, and if you're web-savvy enough to find Daniweb then you're web-savvy enough to search google for your answers first.

>I would appear you have never heard the "Keep It Simple Stupid" rule.
I would say the same about you, since you wasted our time by starting a thread requesting information that could easily have been searched with minimal effort on your part.

>Try not to flame too often.
I only flame people who deserve it.

Narue 5,707 Bad Cop Team Colleague

>I will keep u guys updated.
If you don't care about our input, why should we care about your results?

Narue 5,707 Bad Cop Team Colleague

>It is the best X Box live game i have played
Some of us actually played it before it was on the Xbox. :rolleyes:

Narue 5,707 Bad Cop Team Colleague

>I have to write an algorithm that decides if two structs are structurally equivalent.

#define equivalent(a,b) ( sizeof ( a ) == sizeof ( b ) )

It's as simple as that. Since you didn't specify what you mean by "structurally equivalent", we're free to assume that a byte is a byte and if the size of the structures are the same then they're structurally equivalent.

Narue 5,707 Bad Cop Team Colleague

do{
//prog. body here
} while (answer != 'n')
cout << "goodbye!\n";

You're about six days too late, slick. If you're going to take that long to post a reply to a question that was already answered then at least add something entertaining to the thread.

Narue 5,707 Bad Cop Team Colleague

>Thanks for any help
With what? You didn't ask a question. What do you want me to do, write you a book on all of the topics you mentioned? Or look into my crystal ball and give you information on the subjects that you need yet didn't deign to specify?

If you're a Windows developer then you know how complex threading, sockets and database programming are, so start using your brain and ask for something specific or you'll get nothing but blank stares and flames.

Narue 5,707 Bad Cop Team Colleague

>do you know how to make a program in C that can run the <snip>
Yes, yes I do.

>help me..
Glad to be of assistance.

Narue 5,707 Bad Cop Team Colleague

>i can't find a useful book on how to make the cursor go to a certain part of the screen or something
What part of "platform and implementation dependent" is difficult? If you're looking for a book that tells you how to do this, it's going to be very specialized and thus very difficult to find. I have six letters for you, G.O.O.G.L.E. A braindead search will still give you something to work with.

Narue 5,707 Bad Cop Team Colleague

Just FYI on the assumption that your teacher is an arrogant fool, like most of them seem to be:

>#include <iostream.h>
>#include <iomanip.h>
These are not standard headers. You're probably using a compiler that is very old, so don't be surprised if you see something completely different from what you're used to as an example here.

>char st_name[25];
>char st_major[25],c;
>char st_status[9];
>float f_gpa;
>int i_tuition1;
Global variables should be avoided. You know how to write functions, so you should know how to pass arguments to them.

>void main()
This is where most teachers insist on being stupid. main returns int, nothing else. This is stated in the C++ standard in no uncertain terms. There is no argument in favor of using void main and plenty of proof that it is a very Bad Thing(TM).

>int i=0;
>while((c = cin.get()) != '\n')
>{
>st_major = c;
>i++;
>}
>st_major = '\0';
I notice that st_major is an array of 25 characters. What happens if the user types 25 characters or more? I can guarantee that it isn't a good thing.

Narue 5,707 Bad Cop Team Colleague

>I need help with designing and interface that will search keys.
Your ability to describe the problem in detail is staggering.

>use of avl trees ,b-trees
One or the other? Both? For what purpose? Is the B-tree an external searching structure and the AVL tree an internal searching structure? Have you written the code for these trees or do you just expect their intended use to magically become clear when you have them implemented.

>it should be linked to a database and allow searching.
Would this database be the B-tree?

Narue 5,707 Bad Cop Team Colleague

>Any instructions on the web? I cannot find any.
I could. Strangely enough, they were on the Toshiba support web site. :rolleyes: Rule 1) If it's not easily accessible and you aren't well versed in how to do it, don't screw around. Toshiba recommends that you send in the computer for professional repair on this model, which suggests that it isn't easy. However, from what I've seen of Toshiba, the hard drive is under a panel on the underside of the machine. It's secured by a single screw and everything is easy to get to. Check that first if you want to do this yourself.

Narue 5,707 Bad Cop Team Colleague

>how can i do this?
By opening your Java book and figuring out how to do each of the parts of this program. Can you read a name and a message? Can you write a class to hold a message? Can you display text? Get that working with an array first, then you can switch to a more complicated data structure like a linked list.

And by the way, just about every book on programming out there has a decent description of linked lists along with an implementation. Double linked lists are just a simple jump up from single linked lists. The only relatively hard part is making sure that all pointers are updated properly.

So, what exactly are you having trouble with?

Narue 5,707 Bad Cop Team Colleague

Let me check my helpful meanie guidebook. Hmm, "A double post warrants a sarcastic reply followed by stoney silence. Alternative actions are a brief flame and a pointer to google." Okie dokie.

Search google and do your own damn research! I swear, people these days don't seem to be capable of helping themselves at all, it's always "Do this for me" and "I don't understand the perfectly lucid answer you gave me, show me how it's done by solving all of my problems and giving me the code" or "Here's my incredibly broad question lacking any detail at all, give me the exact answer I need despite the fact that you aren't psychic". It's a good thing we don't have the technology to remotely bitch slap people, or you would be constantly picking yourself up off the floor. And don't double post, it's very rude.

Narue 5,707 Bad Cop Team Colleague

>So is the random number genarator really random
No. The random number generator creates pseudorandom numbers that just look good to a point. Depending on the quality of the generator that point will be quick to arive or not.

>The weird thing is I get 4 like 6 out of 10 times each time I run the program.
That sounds fairly normal. A completely random distribution would have each number equally likely to come up. But pseudorandom numbers aren't quite that good and you can expect slightly skewed results. The best solution is to provide as random of a seed as you can, or replace the random number generator with something better.

Narue 5,707 Bad Cop Team Colleague

>My guess is: i should start from 0?
If you have to guess, don't be so quick to answer questions because you'll probably be wrong. Even if you bother to test your assumptions and they pan out, you could still be wrong on something more subtle.

Narue 5,707 Bad Cop Team Colleague

>i would like to know which system u were working on that returned 224 first time.
The good news is that by the mention of getch (and no mention of curses) you can assume either Windows or DOS. So if it's not DOS proper, it must be a Windows version. ;) Booting into Windows and testing the first return of getch confirms this assumption.

>HOW AM I SUPPOSED KNOW THAT?
Silly teacher. He could have at least guessed that it was an arbitrary extension code that was conveniently a not often used value. :rolleyes:

Narue 5,707 Bad Cop Team Colleague

>believe me.. i searched...a LOT
I believe you, but instead of searching, try thinking. The task isn't a difficult one, it's just a matter of figuring out exactly what you want to do and outlining the steps required to do it. Once you have the steps, you can put them into code in any language you want, but if you don't know the steps then no amount of mastery in C or C++ will help you solve the problem.

So what do you want to do? You want to take a number in word form, such as "one thousand five hundred", and turn it into the number form, 1500. Barring invalid input, all you need to do is notice that the relevant parts of the word form are the words that correspond to digits. So "one thousand five hundred" would become 15 when worked out. From there you're only a special case away from handling zero value digits. Because nothing comes after "hundred", you can place 00 at the end of the number and you have 1500. Modify that for the tens, hundreds, thousands and millions places and you're pretty much done.

Narue 5,707 Bad Cop Team Colleague

>to pause a program just put the header conio.h
conio.h is not a standard header, and on top of that it isn't the correct header to do what you're suggesting.

>system("pause");
system is declared in stdlib.h. But it's a bad idea in general to use system for things like this because it's not portable (the argument will be different on different systems), it's unsafe ("pause" could be a malicious program), and it's slow because it calls the system command interpreter. The same goes for "cls". Your suggestion if implemented correctly will only work on Windows and DOS machines. You should strive for portability wherever possible, and choose the best nonportable option when you can. system is not the best nonportable option.

Narue 5,707 Bad Cop Team Colleague

>but it didnt work
What were you expecting and what did it do that wasn't what you wanted? I can guarantee that you need more logic than that to mask a password entry.

Narue 5,707 Bad Cop Team Colleague

Try something like this:

#include <stdio.h> 
#include <conio.h> 

/* System dependent key codes */
enum
{
  KEY_ESC     = 27,
  ARROW_UP    = 256 + 72,
  ARROW_DOWN  = 256 + 80,
  ARROW_LEFT  = 256 + 75,
  ARROW_RIGHT = 256 + 77
};

static int get_code ( void )
{
  int ch = getch();

  if ( ch == 0 || ch == 224 )
    ch = 256 + getch();

  return ch;
}

int main ( void )
{
  int ch;

  while ( ( ch = get_code() ) != KEY_ESC ) {
    switch ( ch ) {
    case ARROW_UP:
      printf ( "UP\n" );
      break;
    case ARROW_DOWN:
      printf ( "DOWN\n" );
      break;
    case ARROW_LEFT:
      printf ( "LEFT\n" );
      break;
    case ARROW_RIGHT:
      printf ( "RIGHT\n" );
      break;
    }
  }

  return 0;
}
Narue 5,707 Bad Cop Team Colleague

You can find code for this all over the place. Here is how I did it a while back in response to a similar question:

#include <stdio.h>
#include <string.h>

char *wordbuild ( char *n, int ncomm )
{
  int i, nleft, len;
  char *p = NULL;
  static char ret[1024];
  
  /* Word lists */
  static char *ones[] = {"one ","two ","three ","four ",
    "five ","six ","seven ","eight ","nine "};
  static char *tens[] = {"ten ","eleven ","twelve ","thirteen ",
    "fourteen ","fifteen ","sixteen ","seventeen ","eighteen ","nineteen "};
  static char *twenties[] = {"","twenty ","thirty ","forty ",
    "fifty ","sixty ","seventy ","eighty ","ninety "};
  static char *hundreds[] = {
    "hundred ","thousand ","million "};
  
  memset ( ret, '\0', 1024 );
  len = strlen ( n );
  
  for ( i = 0; i < len; i++ ) {
    if ( ( p = strchr ( ( n[i] == ',' ) ? &n[++i] : &n[i], ',' ) ) == NULL )
      p = &n[strlen ( n )];

    if ( n[i] == '0' )
      continue;
    
    if ( ( nleft = ( p - &n[i] ) ) != 0 ) {
      if ( nleft == 3 ) {
        strcat ( ret, ones[n[i] - '0' - 1] );
        strcat ( ret, hundreds[0] );
      }
      else if ( nleft == 2 ) {
        if ( n[i] == '1' ) {
          strcat ( ret, tens[n[++i] - '0'] );
          nleft--;
        }
        else
          strcat ( ret, twenties[n[i] - '0' - 1] );
      }
      else
        strcat ( ret, ones[n[i] - '0' - 1] );
    }
    
    if …
Narue 5,707 Bad Cop Team Colleague

>what do I need to do to show the total of the divisors?
Keep a running total. In StackOverflow's example, look at divisorSum that he neglected to declare. That's the general idea.

Narue 5,707 Bad Cop Team Colleague

Name: Julienne
Nickname: Jewel
Height: 5' 6"
Weight: Less than average
Hair: Blond
Eyes: Green
Location: GA, USA
Age: 26

Hobbies: Reading, rock climbing, frisbee, martial arts.

Relationship Status: Married

Fav Music: Soundtracks

Education: Computer programming

Work: Software engineer

Favorite Movies: Ocean's Eleven, The Last Samurai, anything with Jean Claude Van Damme or Let Li. :)

Favorite TV Shows: Just about any anime, show on Tech TV or Comedy Central.

Favorite Video Games: Final Fantasy (any), Chrono Trigger, Chrono Cross, Xenosaga, Lunar, Lunar 2, Metroid (any), Legend of Zelda, Legend of Zelda: A link to the past, Xwing vs Tie Fighter, Xwing: Alliance, Jed Knight, Jedi Knight 2, Jedi Academy.

Stuff you Dislike: Not much, I'm very laid back. :)

Narue 5,707 Bad Cop Team Colleague

>There are two types of computer programming errors ...
It depends on the language and what you consider compile-time. Compilation usually consists of two distinct steps: compilation and linking. Both of those steps may have errors that are unique to the step. Therefore, I would say that there are three types of errors for compiled languages: compile-time, link-time, and run-time. Link-time and run-time errors are by far the most frustrating. :) For interpreted languages there's no such thing as compile-time, and all errors are run-time whether they're syntax errors or logical errors.

Narue 5,707 Bad Cop Team Colleague

>But now i am facing a new problem.
Post one of the programs that doesn't compile with Dev-C++ and does with Turbo C++. Most likely you're using a library that extension that Dev-C++ doesn't support.

Narue 5,707 Bad Cop Team Colleague

>could you help me in some questions
If you bother to ask them, and in a separate thread unless they are directly related to the original question asked in this thread or one of the replies.

Narue 5,707 Bad Cop Team Colleague

>It should work
No, it should do whatever the hell it wants because you've invoked undefined behavior. And even when the undefined behavior is something intelligent, iostream.h is a nonstandard header, so you can't be sure that cin.get() even exists, much less that it does what you want it to.

Narue 5,707 Bad Cop Team Colleague

>It works fine as for(i=1;i<=n;i++) .
Yes it does. But then again, so does this:

i = 9;
loopie:
  // Do stuff
  if ( --i > 9 - n )
    goto loopie;

Most programmers prefer to use the idiomatic approach because it's easier to use, easier to get used to, and common enough that you don't have to get used to something else everytime you read a different person's program.

Narue 5,707 Bad Cop Team Colleague

> I actually assume that the person asking a question is a beginner
All the more reason to mention better alternatives. Even if they don't understand, they still learn that other options exist.

Narue 5,707 Bad Cop Team Colleague

> while(!cin.eof() )
This is a bad idea and will probably result in you processing the last line of the file twice. A better method is to use your input as the condition:

while ( cin >> numGold >> numSilver >> numBronze )

Without knowing the format of your file, I have to assume that your teacher meant this change:

result[i][0] += numGold;
result[i][1] += numSilver;
result[i][2] += numBronze;

At the end of the file, the array has a total of everything rather than the values of the last line.

Narue 5,707 Bad Cop Team Colleague

>actually i also will use if else.
Your loss. Have fun typing all of that.

>how to use the table driven you mention above?

#include <cctype>
#include <iostream>
#include <string>

struct {
  std::string abbr;
  std::string name;
} state[] = {
  "AL", "Alabama",
  "FL", "Florida",
  "GA", "Georgia",
};

const int nstates = 3;

std::string get_state ( std::string abbr )
{
  // Make abbr upper case
  for ( std::string::size_type i = 0; i < abbr.size(); i++ )
    abbr[i] = toupper ( (unsigned char)abbr[i] );

  for ( std::string::size_type i = 0; i < nstates; i++ ) {
    if ( abbr == state[i].abbr )
      return state[i].name;
  }

  return "NOT FOUND";
}

int main()
{
  std::cout<< get_state ( "GA" ) <<std::endl;
  std::cout<< get_state ( "ME" ) <<std::endl;
  std::cout<< get_state ( "fl" ) <<std::endl;
}

The best part is that the table can be filled from a file, thus keeping the code very short and easy to follow as opposed to your 50 if statements. And if the USA decides to grow, which is probable, you would have to figure out where to change your code, modify it, and then test it to make sure you didn't make a mistake I would only have to add a single quick entry to my input file.

Narue 5,707 Bad Cop Team Colleague

> what is the best way to overclock your processor
The best way to overclock your processor is to realize that overclocking doesn't do as much as you may think, and usually has detrimental effects. Then you can perform a safe upgrade that actually makes a difference. :rolleyes:

Narue 5,707 Bad Cop Team Colleague

>i just learn c++ programming. so i only can get this...
Then don't accept poor code. Try this for the comparison instead:

#include <iostream>

bool is_equal ( int a[], int b[], int size )
{
  for ( int i = 0; i < size; i++ ) {
    if ( a[i] != b[i] )
      return false;
  }

  return true;
}

int main()
{
  int a[] = {1,2,3,4,5,6,7,8,9};
  int b[] = {1,2,3,4,5,6,7,8,9};

  if ( is_equal ( a, b, 9 ) )
    std::cout<<"They're equal"<<std::endl;
  else
    std::cout<<"They're not equal"<<std::endl;
}
Narue 5,707 Bad Cop Team Colleague
System.out.println ( "" + test ( a, b ) );
Narue 5,707 Bad Cop Team Colleague

>make a simple game using Java programming Application
This can be as simple as a number guessing game. You don't have to write the next Quake engine. :rolleyes:

>I'm sure to my self that I cant make it by my own
Then you can't. If you don't believe in yourself then nobody else will.

Narue 5,707 Bad Cop Team Colleague

>i have written this program the way my lecturer has teach us.
You have my sympathy, your lecturer is a moron and clearly doesn't know enough to be teaching.

Narue 5,707 Bad Cop Team Colleague

>nway its not ma homework but a challenge i read from a ma data structures bk.
There's no difference. It's work given to you because you don't know how to do it already. It's not work given to us because we don't care about your book or your class or whatever, and we already know how to do it. The point is that if you don't do your own work, you won't learn squat.

Narue 5,707 Bad Cop Team Colleague

>is there a way for displaying or accessing system folders and files
Yes, but it isn't built into the language. You will need to use a separate library or API. Might I suggest searching around on MSDN?

Narue 5,707 Bad Cop Team Colleague

>now check if the input is valid or not by an if statement giving right parameters
This is okay if the OP is forced to use such a braindead approach. Otherwise a series of 50 if statements is silly, and a table driven approach is far better.

Narue 5,707 Bad Cop Team Colleague

>I know what you are saying, but would you mind listing examples.
The simplest example is an array of pointers. Do you want to compare the value of the pointers or the value of the addresses pointed to:

#include <stdio.h>
#include <string.h>

int main ( void )
{
  static int a = 10;
  static int b = 20;
  static int c = 10;
  static int d = 20;
  int *aa[2] = { &a, &b };
  int *ab[2] = { &c, &d };

  if ( memcmp ( aa, ab, 2 * sizeof ( int ) ) == 0 )
    puts ( "Equal" );
  else
    puts ( "Not equal" );

  return 0;
}

Most likely it's the former, so memcmp would give the wrong answer unless by some coincidence both arrays all have pointers that reference the same addresses.

>It'll be something like this
No it wouldn't, that code is awful. The concept is sound, but the implementation sucks. Here are a few reasons why:

>#include <iostream.h>
Not C++.

>#include <conio.h>
No portable.

>void main()
Undefined.

>clrscr();
VERY nonportable.

>cin>>n;
Not robust.

>for(i=1;i<=n;i++)
Poor style, not idiomatic.

>cin>>a;
Not robust, difficult to recover from on error.

>g=1;
>while(g==1)
>{ g=0;
Confused and awkward.

>getch();
Not portable and stupid because there's a standard alternative that works just as well.

And on top of that, you didn't use code …

Asif_NSU commented: It's good to know there's an uncompromising critic out there-- Asif_NSU +1
Narue 5,707 Bad Cop Team Colleague

>address book i need it now!!!!!
That's nice.

>the program should be able to handle any amount of entries by using linked list and pointers.
Well then, you should start by reading up on linked lists and get cracking rather than expecting other people to do your homework for you. I mean come on, how lazy can you get? :mad:

Narue 5,707 Bad Cop Team Colleague

>Or use memcmp, which essentially does this.
memcmp uses a shallow byte-by-byte comparison, so depending on the type of items in the array this might not be a good idea.

Narue 5,707 Bad Cop Team Colleague

>My program is reading the last line of data from an infile twice.
I'll bet my next paycheck that your file processing loop looks like this:

while ( !feof ( in ) ) {
  /* Read from the file and process */
}

Or this:

while ( !in.eof() ) {
  // Read from the file and process
}

The problem with that is feof (or stream.eof ) only returns true after an attempt has been made to read from the file and end-of-file was encountered. So your loop will iterate once more than you want, and because the input request failed you will use the last successfully read line. The result is that the last line of the file is processed twice.

The solution is to use the return value of your input function as the loop condition:

while ( fgets ( line, sizeof line, in ) != NULL ) {
  /* Process and print */
}

Or

while ( getline ( in, line ) ) {
  // Process and print
}

As an alternative, you can use an infinite loop and use feof or stream.eof in an if statement immediately after your input functions read from the file. That way you can break from the loop before processing the last line twice.

Narue 5,707 Bad Cop Team Colleague

>I posted a Calculator (Windows GUI) in the C snippets
Well, my first reaction wasn't "Eew", but there are some interesting constructs (and one that isn't valid C, so I would say it's either C++ or an Lcc extension). All in all, not too bad for a Win32 program. I'd like to see something that doesn't take advantage of the Win32 API so that I can see the quality of pure C that the translator comes up with.

Narue 5,707 Bad Cop Team Colleague

Dare I ask what the Windows Firewall is doing during all of this?

Narue 5,707 Bad Cop Team Colleague

>i do appreciate your help
I'm glad things worked out for you. :)

Narue 5,707 Bad Cop Team Colleague

>Well some folks are helpful, others like to complain.
I'm helpful enough to justify a goodly amount of bitching. :)

>BCX is not an interpreter.
My appologies, it's your favorite "translator". But my arguments still stand. Any "translator" will most likely not spit out code worth learning from. But if you want to post the C or C++ code that BCX gives you I'd be happy to review it and insert foot in mouth if it's good.