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


The appears 3 times and is a phrase containing one word.
a appears 4 times and is a phrase containing one word.
Left handed material appears 2 times and is a phrase containing three words.
Left handed appears 2 times and is a phrase containing two words.
handed material appears 2 times and is a phrase containing two words.

I still fail to see how you can tell a computer program how to determine what a phrase is. What distinguishes one phrase from another ? Do you remove the words "the", "a", "an", and "and", then what remains is a phrase ?

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

>>But is it possible to convert a string object to an istream obj
No. Why would you want to do that anyway ?

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

>>e.g. 'The' occurs 25 times (one word phrase), 'negative refractive index is' occurs 12 times (four word phrase)

How about "The negative refractive index is" -- Is that one phrase or two phrases. Or is it 5 one-word phrases ? In otherwisds, the description you have posted is ambiguous and makes no sense.


>>I am having trouble making any character except 'Y' or 'y' terminate the programme

>> if (choice == "n")
Then change that to if( choice == 'y' && choice != 'Y')

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

>>I think that i can use pthreads in c++ code but is there any way to use threads in c++ ,in an object oriented manner?
There might be some obscure c++ objects out there, such as the Microsoft Foundation Class (MFC) which is only useful for wring MS-Windows windows. Boost libraries have a threading class that.

>>Is it common for "everyday" applications (in todays multicore platforms) to use threads?
Yes, it is very common. If you are running MS-Windows start up the Task Manager, view the Processes tab then you can see how many thread each process has started. You might have to select View --> Options to get that column.

>>I have "googled" it, but i was wondering if anyone with hands-on experience has something to say.

Theread aren't reall all that difficult to start. Here are a few google links you should read. You can ignore the ones about MFC unless you are using that which is doubtful.

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

line 59: use index variable instead of numstudents. in>>person[index].studentFName>>person[index].studentLName>>

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

Oh yes, here the problem if(student[j].lastname[0] > student[j+1].lastname[0]) change it to this and it will work if(student[j].lastname > student[j+1].lastname) Actually I would think you need to sort by both last name and first name, so that when two or more people have the same last name the function will sort those by first name.

void alphasort(if1 student[], int n)
//the alphasort function will sort the records into alphabetical order by last name. It expects the list as well as the total number of 
//names and will return the sorted array. The basic format for this function came from the class handout on bubblesorting.
{
    if1 temp;//used as a swapping mechanism
    int i; int j;// used for implementing for loop checks
    int f=1;//used for checking letters after the first
    for (i=0; i < n-1; i++)
    {
        for (j=0; j < n-(i+1); j++)
        {
            string n1 = student[j].lastname;
            string n2 = student[j+1].lastname;
            if(n1 == n2)
            {
                n1 = student[j].firstname;
                n2 = student[j+1].firstname;
            }
            if(n1 > n2)
            {
                temp = student[j];
                student[j] = student[j+1];
                student[j+1] = temp;
            }
        }
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The program crashes during sort because it is attempting to reference non-existant index value. I simplified alphasort() algorithm as shown below and everything works ok.

struct if1
{
  string idnum;//id number for the student
  string lastname;//last name of student
  string firstname;//first name of student
  int examscore[maxexam];//array of all the exam scores of the student
  int hwscore[maxhw];//array of all the home work scores of the student

  void operator=(if1& f1)
  {
      idnum = f1.idnum;
      lastname = f1.lastname;
      firstname = f1.firstname;
      memcpy(examscore, f1.examscore, sizeof(examscore));
      memcpy(hwscore,f1.hwscore,sizeof(hwscore));
  }
};

...
...
<snip>
...

void alphasort(if1 student[], int n)
//the alphasort function will sort the records into alphabetical order by last name. It expects the list as well as the total number of 
//names and will return the sorted array. The basic format for this function came from the class handout on bubblesorting.
{
    if1 temp;//used as a swapping mechanism
    int i; int j;// used for implementing for loop checks
    int f=1;//used for checking letters after the first
    for (i=0; i < n-1; i++)
    {
        for (j=0; j < n-(i+1); j++)
        {
            if(student[j].lastname[0] > student[j+1].lastname[0])
            {
                temp = student[j];
                student[j] = student[j+1];
                student[j+1] = temp;
            }
        }
    }
}

Attached is the output file it produced

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

Would you also post the input files? Just attach them to your post .

Here is what I had in mind for the structure, but I need the input files for testing.

struct if1
{
  string idnum;//id number for the student
  string lastname;//last name of student
  string firstname;//first name of student
  int examscore[maxexam];//array of all the exam scores of the student
  int hwscore[maxhw];//array of all the home work scores of the student

  void operator=(if1& f1)
  {
      idnum = f1.idnum;
      lastname = f1.lastname;
      firstname = f1.firstname;
      memcpy(examscore, f1.examscore, sizeof(examscore));
      memcpy(hwscore,f1.hwscore,sizeof(hwscore));
  }
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

please post your code. Its kind of hard for me to see your monitor from where I am sitting.

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

What I'm doing is writing my own version of the = operator. So when you way temp = student[j]; the compiler will call my version of the = operator instead of the compiler's default version. The parameter to the operator is the equilivent of passing student[j] by reference to any normal function.

I believe the reason your sort does not work as you wrote it is because the structure contains c++ STL class -- std::string. In such cases when the structure includes other class objects you should write the overloaded = operator.

That might also be similar to writing a swap function

void swap(if1& f1, if1& f2)
{
    if1 temp;
    temp.idnum = f1.idnum;
    temp.lastname = f1.lastname;
    temp.firstname = f1.firstname;
    temp.examscore = f1.examscore;
   temp.hwscore = f1.hwscore;

   f1.idnum = f2.idnum;
   // etc for f1

   f2.idnum = temp.idnum;
   // etc for f2
}

As you can see, the above code is pretty lengthly. The overloaded = operator is consideratly shorter and less pron to typing errors.

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

structs are nearly identical to classes, so maybe you need to add an = operator

struct if1
{
  string idnum;//id number for the student
  string lastname;//last name of student
  string firstname;//first name of student
  int examscore[maxexam];//array of all the exam scores of the student
  int hwscore[maxhw];//array of all the home work scores of the student

  void operator=(if1& f1)
  {
       idnum = f1.idnum;
       // etc for the rest of the structure members

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

>>I have taken if(infile.is_open()) away as seen because when having this I received the size of: 0. I am not sure if this was okay to do ?

Don't do that. If is_open() fails that means the file could not be opened for some reason. And in that case all other fstream functions will fail too. You need to find out why the file can not be opened.

>>Getsize2 = Getsize.str();
You don't need Getsize2 string. String^ sizeee = gcnew String(GetSize.str());

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

1) file size is an unsigned integer not a double.

2) >> double filesize = path.size();
All that is doing is getting the number of characters in the string, not the file size

Here is how to get the file size

size_t fileSize = 0;
string path = "C:\\Folder1\\Folder2\\OneFile.txt";
ifstream infile(path.c_str());
if(infile.is_open())
{
    infile.seekg(0, ios::end ); // move to end of file
    fileSize = infile.tellg();
}
cout << "file size is " << fileSize << "\n";

There are a couple other ways to get it, such as calling the stat() function.

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

The atmosphere in Vegas is what I find appealing, its not really about the gambling! Posh hotels and restaurants - nice!

prostitutes :) STD :) Nevada (where Los Vegas is) prostitution is legal for any county of less than 400,000 people. That doesn't mean they are clean, only that they MAY BE legal.

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

pipes don't work at all in win32 programs, only console programs on Ms-Windows platforms. See the discussion here for work-around.

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

Is it a joke ?!

No. Did you read the link I posted? MSDN says the first time ShowWindow is called SW_HIDE might be ignored. After that SW_HIDE parameter is honored.

vedmack commented: Helped me, Thx +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

depends on what that function does.

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

If you travel to Los Vegas make sure you have an unlimited amount of cash :)

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

Try calling ShowWindow twice, according to MSDN the second parameter to ShowWindow() might get ignored the first time it is called. I don't know if it will work, but its worth a try.

HWND hWnd = FindWindow(NULL, sName);
if(hWnd)
{
	ShowWindow(hWnd, SW_HIDE);
	ShowWindow(hWnd, SW_HIDE);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
  • Eating ice cream for 24 hours without gaining weight.
  • Learning to play a musical instrument such as piano in 24 hours.
  • Spend the day at a health club without getting too exhausted.
  • Be the President of USA for a day.
  • Fly to UK and spend the day in London.
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

by making one small change I get this:

Please enter your airline name: stl
Please enter your flight number: 100
Please enter your origin: stl
Please enter your destination: mo
Please enter your departure information: adf
Please enter your arrival information: lkj

Airline: stl
Flight Number: 100
From: stl
To: mo
Departure: adf
Arrival: lkj
Press any key to continue . . .

I added cin.ignore() after line 29 in the *.cpp file.

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

>>"Mythology"[5] ; is a valid c statment.
Its a do-nothing statement. char c = "Mythology"[5]; is a valid statement.

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

>>and I'm supposed to include an application file, but I don't have the slightest clue by what the professor means by that
The application file is a *.cpp file that contains main(). I would assume from your comment that main() should not be in the same file as the class implementation. So your project would consist of a header file and at least two *.cpp files.

Appears you are mixing up the variables in lines 7-12 of the header file and lines 15-20. Just delete one of the two sets of variables so that it isn't so confusing.

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

When using the term string literal, yes that is correct.

integers can also have literals. Example: int x = 123; In that the value 123 is a literal, sometimes called magic number or constant value.

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

worked for me. delete all references to SIZE and call resize() after you know how many elements are to be entered.

how many tests will you be entering? 5
enter score for test 1 : 5
enter score for test 2 : 3
enter score for test 3 : 1
enter score for test 4 : 2
enter score for test 5 : 4
5
4
3
2
1
your average score is: 3
Press any key to continue . . .
int main()
{
     int count=0;
     int testNum=0;
     vector<int> test;
     int Avg1=0;
     double Avg2=0;
     
     cout <<"how many tests will you be entering? ";
     cin >> testNum;
     test.resize(testNum);
     for (count=0; count < testNum; count++)
     {
      cout << "enter score for test "<< count+1<<" : ";
      cin >> test[count];
      Avg1+=test[count];
     }
     Avg2=static_cast<int> (Avg1)/testNum;
     
     testSort(test);
     
//this is to show the grades in acending order

     for (int count = 0; count < testNum; count++)
     {
          cout<< test[count] << "\n";
     }
     
     cout << "your average score is: " << Avg2<<endl;
      
     
     system("pause");
     return 0;
}

void testSort(vector<int>& test)
{
     
     for (unsigned int startScan = 0;startScan < (test.size()-1); startScan++)
     {
         for(unsigned int count = startScan +1; count < test.size(); count++)
         {
          if (test[startScan] > test[count] )
             {
                 int temp = test[startScan];
                 test[startScan] = test[count];
                 test[count] = temp;
             }
          }
     }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It is not the string but the text inside the quotes. It could be either c or c++. cout << "Hello World\n"; That is also a literal.

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

A literal is a string of characters inside quotes. For example char str[] = "Hello World"; In the above, "Hello World" is considered the literal.

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

It is my mispelling of int. I hit the wrong keys and didn't notice it.

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

what exactly is "ubt?" I can't find it in my book.

I have no idea either. Where did you see that ?

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

You get that error because you are passing a vector and the function wants an int array. Not the same thing. So just change the function to this:

Note, this doesn't need the second parameter SIZE because vectors know their size.

void testSort(vector<int>& test)
{
    for (int startScan = 0;startScan < (test.size()-1); startScan++)
    {
         for(int count = startScan +1; count < test.size(); count++)
         {
              if (test[startScan] < test[count])
             {
                  int temp = test[startScan];
                  test[startScan] = test[count];
                  test[count] = temp;
             }
          }
     }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is how I code that function.

void testSort(int test[], int SIZE)
{
    for (startScan = 0;startScan < (SIZE-1); startScan++)
    {
         for(int count = startScan +1; count <SIZE; count++)
         {
              if (test[startScan] < test[count])
             {
                  int temp = test[startScan];
                  test[startScan] = test[count];
                  test[count] = temp;
             }
          }
     }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have no idea what it is doing either, but it displays an interesting map.

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

try using unsigned char

int main()
{
unsigned char ch = '—';
cout << static_cast<int>(ch) << "\n";
if( isprint(ch))
    cout << "TRUE\n";
else cout << "FALSE\n";
}

output is 151
FALSE

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

>> it does not say non-believers will perish
True -- and I think its because their status is ambiguous as far as we are concerned.

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

If you want to check for printable characters you can use the isprint() macro in ctype.h. What is the decimal value of the '—' you are talking about.

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

Sneek, you missed the point (and so did AD), he made a claim - I just wanted him to back up the claim. Your quote does not back up his statement. The claim was roughly 'non-xtians are doomed - it all over the bible'. I just wanted him to support his argument; I am certainly not interested in doing his research for him (or for you for that matter).

[edit]OMG I just noticed that I edited your post instead of quoting it. My deapest apologies for my error -- AD [/edit]

.

I already told you that I have no intention of turning this thread into any type of religious war. I'll say it again -- You want a quote: just ONE is John 3:16

For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.

There are similar claims all over the New Testiment. Also note that this only applies to people born after Christ was born and who are aware of his teachings. That means everyone born in BC, all children under certain age, and people who never heard of Christ are exempt. So the contention that everyone is doomed is not correct.

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

If you look at the standard ascii chart you will see that it contains 256 entries, some are printable but most are not. This ascii chart only contains characters in the English language. Other languages will use different charts to accommodate the language that is installed on the computer.

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

Yes, vectors are very easy to use. You would loop through the vector just like you would loop through any other normal array

for(int i = 0; i < theList.size(); i++)
{
    if( theList[i] == "Alkesh" )
    {
       cout << "Found at array element number " << i << "\n";
    }
}

Tutorial here

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

If you use the vector class you don't have to know how many words there ahead of time. Just read the file once and add each word to the vector -- it will expand as necessary to contains all the strings

#include <vector>
#include <string>
#include <fstream>
#include <iostream>
using namespace std;

int main()
{
    vector<string> theList;
    string word;
    ifstream infile("filename.txt");
   while( infile >> word)
       theList.push_back(word);
   // after the above loop finishes the vector will
   // contain all the words.
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

it would help if you would learn how to format your code better.

int main()
{
    int Rand, Cent, Pounds, Shillings; // pound = 20 shillings

    do
    {
        cout << "Enter Pounds: " << endl;
        cin >> Pounds;
        cout << "Enter Shillings: " << endl;
        cin >> Shillings;
    }while (Pounds != 0 && Shillings != 0);

    // Calculate & convert pounds to rands    
    Rand = (Pounds * 2 );

    // Calculate & convert shillings to cent        
    Cent = (Shillings * 10);                          

    cout << "The pound is equells to R "<<Rand << endl;    
    cout <<"Shilling equells to "<< Cent<< " C "<< endl;

    return 0;
}

As you can now see, the loop continuously asks for the #Pounds and Shillings until one or the other is 0. Each time you enter the amounts the previous amounts are destroyed. You probably should move lines 16-20 up inside the loop, after line 10.

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

It would be nice to know what this program is intended to do. It is trying to convert pounds and shillings to something, but I don't know what.

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

Dev-C++ uses the *nix ar archiver. You can find info here

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

Its probably the way you created the project. This link suggests you start with an empty project. You might also read some of these links.

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

except that it doesn't check bounds

at() and [] both throw exceptions on out-of-bounds, at least it does with VC++ 2008 Express.

[edit]Nope, I'm wrong. Adding try/catch block the at() will throw and exception, but [] will just simply crash. But this is not relevent if the coder doesn't use try/catch blocks.[/edit]

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

I think women live longer than men because we were an upgraded model of the human being.

Reminds me of the below :)

O/T Dear Tech Support
Subject: Computer Hard and Software:
Dear Tech Support:
Last year I upgraded from Girlfriend 7.0 to Wife 1.0.
I soon noticed that the new program began unexpected child
processing that took up a lot of space and valuable resources.
In addition, Wife 1.0 installed itself into all other programs and
now monitors all other system>activity. Applications such as Beer
Night 10.3, Cricket 5.0, Hunting and Fishing 7.5, and Racing 3.6 no
longer run, crashing the system whenever selected.
I can't seem to keep Wife 1.0 in the background while attempting
to run my favorite applications. I'm thinking about going back to
Girlfriend 7.0, but the uninstall doesn't work on Wife 1.0. Please
help!
Thanks,
A Troubled User.
______________________________________
REPLY:
Dear Troubled User:
This is a very common problem that men complain about.
Many people upgrade from Girlfriend 7.0 to Wife 1.0, thinking that
it is just a Utilities and Entertainment program.
Wife 1.0 is an OPERATING SYSTEM and is designed by its Creator
to run EVERYTHING!!!
It is also impossible to delete Wife 1.0 and to return to Girlfriend
7.0. It is impossible to uninstall, or purge the program files from
the system once installed.

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

1) when using vectors you can access individual elelements just as you would do with a simple int array B = LiDARGrid.ConcentricScans.[scancounter].getColumn(concentriccol); Otherwise, this works. Your problem is probably something other than push_back

#include <vector>
#include <iostream>
using namespace std;

int main()
{
vector<double> Saved;
for(int i = 0; i<10; i++)
{
    if( (i%2) == 0)
        Saved.push_back(i);
}
vector<double>::iterator it;
for(it = Saved.begin(); it != Saved.end(); it++)
{
    cout << *it << "\n";
       
}


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

in the constructor the default radius should be 1, not 0 because that's what you make it in setradius()

you don't need the loop in getradius(). Just return the radius.

To answer your question: The instructions aren't very clear about the 20-30 thing but I suppose a loop might be the best way.

sphere sp;
for(int i = 20; i < 31; i++)
{
    sp.setradius(i);
    sp.print();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think menu Project --> Add To Project, then select the library you want to add. Could be wrong about that though.

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

The only reason to pass a pointer to a pointer is so that the function can change the value of the original pointer that was declared in main().

>>for(i=1;i<= int_tmp;i++)
That line is incorrect. arrays are numbered 0, 1, ... Here is the correction for(i=0; i < int_tmp; i++) >>for(i=1;i<=N_Cell_total;i++)
From your original post in main() -- that line is also wrong for the same reason for(i=0; i < N_Cell_total; i++) And don't be afraid to make liberal use of white space, it make the code easier to read.

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

Come on, AD - give it up! We want a hint - I think the standard is book - chapter - line(s) (zeke 12: 13-69).

I'm not turning this thread into a religious discussion. Read the new testiment yourself if you really want to know.