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

>> You condemn Josh as racist, yet don't give a reason.
If you don't know the reason then your intelligence is a lot lower than I thought it was. It doesn't take intelligence to see recism when its glaring me right in the face. Josh seems to be a member of some white supremist group and believes he knows it all because he has an IQ of 135. I now understand his obnixious behavior in other threads.

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

Well yes its possible, but why would you want to do it? Unless, of course you are passing a pointer to another function.

Employee emp;
Employee* ptr = &emp;
ptr->display();
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That while statement on line 13 is incorrect because eof() doesn't work like that. Instead, code it something like this

string line;
while(getline(infile, line) )
{
     // now split this string into individual parts for the structure
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Oct 18, 2007

LONDON, England (CNN) -- A British museum has canceled a lecture by Dr. James Watson, co-discoverer of the DNA double helix, after he claimed black people are less intelligent than whites in a recent newspaper interview.


James Watson won the 1962 Nobel prize for discovering the structure of DNA.

Watson, who won the 1962 Nobel prize for his part in discovering the structure of DNA, provoked a storm of criticism after his comments were published in the Sunday Times.

The eminent biologist told the British newspaper he was "inherently gloomy about the prospect of Africa" because "all our social policies are based on the fact that their intelligence is the same as ours -- whereas all the testing says not really."

Watson, 79, had been due to give a lecture at London's Science Museum on Friday but the museum canceled his appearance, saying his comments had "gone beyond the point of acceptable debate."

The American professor's words have been roundly condemned as "racist," with fellow scientists dismissing his claims as "genetic nonsense."

So much for your expert's opinion! as well as your unsupported claim that "There are many more scientists who back-up Watson".

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

i read from the file using this:

fscanf(in, "%[^:]:%[ ^:]:%[ ^:]:%d:%lf", empNum, lName, fName, &pGrp, &hrsWorked);

I tested this and it works: fscanf(in, "%[^:]:%[a-zA-Z0-9]:%[a-zA-Z0-9]:%d:%lf", empNum, lName, fName, &pGrp, &hrsWorked)

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

*Disclaimer* This is just a theory that seems to fit the evidence and statistics I posted. Do not label me a hick/racist/redneck. I am in fact a college student who scored in the 95th percentile on the SAT, was ranked at the top of my class, and who is currently at the top of my engineering class... and my IQ is a 135.

All that shows is that you are an smart and educated hick/racist/redneck. Intelligence is no excuse for racism nor does it prevent racism.

Ezzaral commented: My thought as well. +4
jbennet commented: racism is a stupid word. Some races are naturally better at some things than others and its stupid to deny it -4
lasher511 commented: yep me 2 +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The function is doing a case-sensitive search -- maybe the search string is not the same case as the strings in the array. You might to a case insensitive compare by converting both strings to all upper case (or lower case) before performing the comparison. Otherwise I see no reason for the code you posted to fail.

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

I never type it manually -- just click a link. No point in wearing out my fingers :)

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

>>Like overtaking on roundabouts
what idot would do that? The roundabouts we have in US are not wide enough to attempt that.

>>and doing 100+ on the motorways.
I've done that -- 35 years ago. Too many autos nowdays where I live. But there are still a lot of places where 100+ MPH is possible when the road is straight as a string and no one in sight for several miles.

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

Did you make any attempts at all to do your own research, like read some of these google links? Or google for the algorithms you want, such as these links?

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

>>plsss....anyone help me........
If you would read your text book you could help yourself.

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

>>My question is ,is it really addres or i am wrong informed and if it addres how to use in Dev-C++?is it possible?

Yes, as far as I know, those are the actual memory address. You can not access them directly with any 32-bit compiler unless you write your own device driver as Vijayan posted.

What is it that you want to do? There is probably another way to do it without accessing actual memory locations.

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

line 12: never ever use gets() because it can destroy your program. Use fgets() instead.

line 15: you don't need an array of temp pointers. Just one temp pointer will do.

I've always coded the bubble sort like this: Note that the inner loop begins one slot beyond the current position of the outer loop. There is no point in checking positions 0 to i because they have already been sorted.

char* temp;
for (int i=0; i< words-1; i++) {
  for ( int z= i+1 ;z <  words; z++ ) {
    if (strcmp(pch2[ i ],pch2[ z ]) > 0) {
           temp = pch2[i];
           pch2[i]=pch2[z];
           pch2[z]=temp;
     }
  }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've seen typing tutorials that teach touch typing that are like that. They display a character or whole word and wait for you to type it.

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

>>is the assembly code outputted MIPS
No. Its Intell 80X88, you will have to translate it to MIPS.

You can get free eVC++ 4.0 which is for embedded WinCE and PocketPC devices which can produe MIPS assembly. Depending on your program that compiler may or may not be able to compile it.

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

Project --> Properties (the last item in the menu) --> Configuration Properties --> C/C++ -> Output Files --> then on the right side of the screen you will see Assembly Output

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

VC++ 2005 Express can produce the assembly code for you but it won't produce assembly code for the standard c and c++ library functions that your program calls. Unless your teacher lets you link with standard C or C++ libraries, which I doubt, you wil have to write those functions yourself.

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

Ok, I see that now. well, the easiest way to do it is like this:

ifstream in("infile.txt"); // or whatever file name you gave it
ofstream out("outfile.csv");
string word;
string line;
while( getline(in,line) )
{
   stringstream stream;
   stream << line;
   while( stream >> word )
   {
         out << word << ",";
   }
   out << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You may not have to do anything with that file other than rename it with csv extension. If paraview is like Excell then you can specifiy column deliminator, and in your case it is a space. If paraview can not do that, then your program should be fairly simple

open input file
open output file
while getline() is ok
    replace all spaces with a comma
    write line to the output file
end of while loop
end of program

If you use std::string objects your job is very simple because it has a function to replace all instances of one character with another.

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

I think the job of that function is to create a third linked list that is the union of l1 and l2

Void uinio(linkedlist l1,linkedlist l2)
{
    struct node* l3 = 0;
    struct node* node = l1;  
    // add the unique node in l1 to the new linked list
    while( node )
    {
        if( !IsMemberOf(l3, node->data) )
        {
              // add node->data to l3 list
        }
        node = node->next;
   }
   // do the same thing with l2
   node = l2;
    while( node )
    {
        if( !IsMemberOf(l3, node->data) )
        {
              // add node->data to l3 list
        }
        node = node->next;
   }

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

try using your compile's debugger so that you can execute the program one line at a time and see what the variable values are. When in that code snippet is the infinite loop ? what value of search_prod causes the infinite loop? Possibly the problem isn't even in that function but somewhere else in your program, for example trashing that vector.

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

>>is there a way to know what it is expecting you to type?
Not unless you have found some kind of mind reading program or a crystle ball :) There are no functions that can anticipate what you are to type. You will have to type the answer and press the Enter key before the program can proceed and use that information. There are however ways to have the program do othere things while it is waiting for your entry -- that's called multiple threads.

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

Yes, I agree you should leave those lines where they are because of line 27.

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

>>Is that what I want there?

Probably not. The problem is somewhere else. Remember that after executing that function the last one or two locations in the new array do not contain valid data. How many elemenets are invalid depends on the difference between the original size and the new size.

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

That loop should copy the original number of entries, not the new number, and use < operator, not <=.

void DateArr::resize(int newSize)
{
	Date* newTempArr;
	newTempArr = new Date[newSize];
	for (int i=0; i < size; i++)
		newTempArr[i] = arr[i];
	size = newSize;
                delete[] arr;
                arr = newTempArr;

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

>>error: glibtop.h: No such file or directory
Either you don't have glib installed on your computer or you need to tell your compiler where to find it.

>>Or to give me another idea like how to get info from /proc/cpuinfo
Don't know, but someone else probably does.

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

that loop still has the division by zero problem. You need to use another if statement

while( (x+y) != 0)
{
  ... <snip>
   if( (x+y) != 0)
   {
         h= harmonic(x,y);       
         cout <<"The harmonic mean is: \n" << h <<endl;
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Ma, I'm going to rip off your head and shit down your throat!

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

you could also use c++ std::map class, but may or may not be too advanced for you at this time.

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

elite: you are still wrong! That does indeed copy the pointers but the class needs its own copy of those strings because the calling function may change the string contents. If you need to use character arrays then declare them as in the original post but in the class constructor you have to call strcpy to duplicate the string so that the calling function can not change the string contents.

My personal preference is to use std::string class instead of character arrays, but the OP may not be able to do that.

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

>>I'm sorry but after browsing the FAQ and "read me first" thread I could not figure out how to add line numbers to the code
very simple: [code=c++]

Formatting is still very bad and hard to read. Here is one way to do it right. Notice indentation and placement of braces. You can immediately see the beginning and ending of blocks without hunting all over the code for them or manually counting braces.

void shopping_cart::search_inventory(vector<product> list)
{
    string temp_name,search_prod;
    product temp;
    bool found=false;
 
    cout<<endl<<"Enter product name: ";
    getline(cin,search_prod);
    search_prod=StringUpper(search_prod);

    while(!found)
    {
        for(unsigned int i=0; i<list.size();i++)
        {
            temp=list[i];
            temp_name=temp.get_product_name();
            temp_name=StringUpper(temp_name);
            if(temp_name==search_prod)
            {
                found=true;
                inventory_position=i;
            }
        }
        if (!found)
        {
            cout<<"\nProduct not found. \nPlease re-enter product name or enter xxx to return to main menu: ";
            getline(cin,search_prod);
        }

        if(search_prod=="XXX")
        {
            inventory_position=-1;
            found=true;
        }
    }
}

put a break; after line 21 to stop that loop.

I would also move lines 30-34 up outside that while loop because there is no point searching and comparing when search_prod == "XXX".

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

YES, Thank you for that link.

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

1. move line 12 up outside the do loop, between lines 8 and 9. Once the string is converted to upper case there is no point in repeating that process.

You need to reformat the code to make it easier for us to read and understand. It's great that you used code tags, but they don't help badly formatted code.

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

elete: lines 43, 45 and 47 of the code you posted are wrong. C-style character arrays can not be copied like that. You have to call strcpy function to copy them.

tones:

line 33: close, you forgot to make the variables pointers, see the stars here: Employee(char* last_name = "", char* first_name = "", char* ss_num = "0", double salary = 0, int years_employed = 0);

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

I created a cmd.exe command prompt window and tried to execute "telnet towel.blinkenlights.nl" -- got error that telnet now found.

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

you could use an array of structures

struct phrases
{
    char* correct;
    char* response;
};
phrases  ph[] = {
   {"CU","See You\n"},
   {":-)", "I'm happy\n"},
 // etc
};

   cout << "Enter phrase>";
    cin >> input;
  for(int i = 0; i < sizeof(ph)/sizeof(ph[0]); ++i)
  {
        if(stramp(input, ph[i].correct) == 0)
        {
             cout << ph[i].response;
             break;
        }
   }
vmanes commented: Clever solution. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 8 and 9: initialize the array with 0s. int account[100] = {0}; float balance[100] = {0.0F}; lines 13 and 14: delete (see above)

line 10: Const is misspelled should be const

delete line 24 because it will be calculated on line 26.

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

>>Is there any way to easily change what I have, to what I am supposed to have?

Depends on your definition of easily :) It will require some rewriting of each of those cout lines, but shouldn't been too difficult. Something like below (not compiled or tested)

#define PRINT_DOT (cout << ".";)
#define PRINT_DASH (cout << "-";)

...
case A:  PRINT_DOT PRINT_DASH cout << "\n\n"; break;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It might help to explain your problem is you show something that illustrates what you want to do, because I have no clue what you want.

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

I believe a nice big nuclear detonation about 100 ft above the ground should fix them pesty insects.

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

try this: It does a case-sensitive comparison, such as "Rudolf" is not the same as "rudolf"

#include <iostream>
using namespace std;

int main()
{
    char input[20];
    char correct [] = "Rudolf";
    cin >> input;
if (strcmp(input, correct) == 0)
    {
              cout << " correct";
    }
    else
    {
              cout << "incorrect";
     }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

doesn't work on MS-Windows os.

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

Just make sure you use a Nightly Build!

why? does the compiler change from day-to-day?
[edit]After reading the link you posted I see what you mean. Yes the compiler might change on a daily basis[/edit]

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

1. you can not initialize c-style character arrays like you are trying to do in the class constructor. My suggestion is to declare them as c++ string objects. If you can not do that then to initialize the arrays to empty string just set the first byte to 0, like this: last_name[0] = 0; line 30: you have to add the parameter names as well as their data types, and declare them as const because they are unchangeable by the setName function. void setName(const char* LastName, const char* FirstName); You need to change the other methods in lines 31-34 the same way.

line 40: too many parameters -- see line 30

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

TemporaryBalance needs to be declared as either type float or double because integers do not contain decimal values.

line 22: syntax error -- here is correction: int linearSearch(const int array[],int size, int findnumber) lines 11-16: If the account is not already in the array then you have to add one. You need another linear search algorithm to find the next available slot in the array, which is probably not the same as the i counter in the loop that starts on line 6. So if you initialzed the array to all 0s when the arry was declared all you have to do is find the first slot that contains a 0 value. And you don't need the loop at line 6 at all -- just use

while( indata>>temporaryID>>temporaryBalance )
{
    index=linearSearch(account, array_size, temporaryID);
    if( index < 0)
    {
          // set index to the next available slot in the array not shown here.
          ...
          account[index] = temporaryID;
    }
    balance[index]+=temporaryBalance; 
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You didn't post the include file(s) -- you DID include the headers for AnsiString didn't you ?????

line 3: remove the semicolon between AnsiString and Line.

line 6: you have to declare all functions before they can be used. If the function is not coded before the function in which it is used, then you must prototype it. Put this above line 1 (above main()) AnsiString ReadStringPr(const char* prompt); line 10: where is Length declared?

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

Here is an introductory tutorial -- and you can keep your free book

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

. I really hope it's not a sign of something messed up with our tectonic plates.

No -- its just the coming of the end of the world in 2012 :)

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

>>The function should return the answer to main(),
That means that the function has a return type that is NOT void. The reason for the float typecasts below is to avoid the problems with integer division. With integer division all fractional parts are simply discarded, for example 1/2 is 0 but 1.0 / 2.0 is 0.5.

float harmonic(int x, int y)
{
    return (float)((2.0*x*y)) / (float)(x+y);
}

int main()
{
  ...
   h =  harmonic(x,y);
  ...
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Will that work for:
John Smithers 2031 West Alberta Street Sioux Falls South Dakota 65565? :icon_rolleyes:

Yup, works for that too! It just won't give the OP the result he wants :)

while( getline(cin,name) )
{
    getline(cin,street);
    // etc
}