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

I'm now confused about what you are trying to do. Neither of those functions will read the registry and give you an icon for the file type. In fact there is no function that will do that because there are no standard icons for specific file types. The icons for MS-Windows applications are included in the program's resource, which is part of the *.exe and it can be anything the developer chooses it to be.

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

GetFileName() and GetModuleBaseName() have nothing at all to do with registering file extensions. Extensions are registered in KEY_CLASS_ROOTS

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

>>while(1);
That's an infinite loop

>>void main()
Not a good thing to do. Here's why.

The function just above main is missiong a closing }

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

I think I've posted in games only once or twice since I started at DaniWeb. Most of mine are in C and C++ boards, with a few in Geeks Lounge and even less elsewhere.

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

The Moody Blues -- one of my favorite music groups.

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

I listened to Johnson's speech -- very funny man. He promised to build 50,000 public homes. We tried that in USA too and it was a disman failure. The homes were turned into slums in very quick time.

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

>>I have an assignment due tomorrow
So why did you wait so long before starting it? You can't be a procrastinator in computer programming because its probably the most time consuming course you will ever take in college.

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

Did Obama win by seven votes!?

In Gaum caucases, yes. Considering they only had about 5,000 votes total it isn't much of an achievement.

Results of the count completed Sunday morning Guam time show Obama with 2,264 votes to 2,257 for Clinton's slate

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

why would you want to remove the duplicates ? The distance from London to Paris is going to be different than from London to New York. So you would need London in that array twice.

It would probably be easier to do what you want by using two different arrays of city names then trying to stuff both city1 and city2 into the same array as you are doing on lines 50 and 51.

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

The easiest was is not to put the duplicates in the array in the first place. When you read a city name from the file check to see if the name is already in the array. If not, then add it.

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

look at the function parameters and then look at what you are trying to pass. There apparently are some difference. I'd say you're trying to pass a pointer where its not supposed to be a pointer, or vice versa.

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

obama

Popeye

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

Welcome! Stephen King is the greatest author of the 20th century. I am a slight addict to his works. Besides The Dark Tower, IT is the greatest thing he has written.

Others will disagree with that.

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

Welcome to DaniWeb. Sounds like you are really enjoying yourself in Cambodia :)

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

don't get mad, get even ,throw out the computer !
.

Don't laugh -- I did that once. I got to angry that I tossed the computer, monitor and all books out the back door and smashed it all on the concrete patio! I felt great after doing that :)

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

>>int position
should be size_t position because negative positions are not valid and size_t will allow for files twice the size (about) as int.

>> char word[]
use std::string here to avoid the many problems with character arrays.

use a vector instead of that huge array because vector will expand as needed.

call tellg() to get the position then the >> operator to read the word.

struct storagefile
{
	int fileno;
	std::string word;
	size_t position;
};
vector<storagefile> sf;
storagefile item;
ifstream in("file.txt");
memset(&item, 0, sizeof(item));
item.fileno = 1;
while( in >> item.word )
{
    sf.push_back(item);
    // get ready to read the next word
    item.position = in.tellg();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What makes you believe that information is in the registry ?

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

I've gotten a lot of helpful code from codeproject over the last 10 years. If you think all it has is copies of MSDN examples then you are woefully misinformed.

>>Then see MSDN, where there is a complete sample for an explorer, with TreeView + Splitter + ListView
You might be right about that.

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

>>Could someone please tell me how can i open a txt file with a press of a button (MFC)?
In the OnClick() event handler for the button.

>>Is there any way i can transform a cpp file to a txt file
No conversion needed -- the *.cpp file is already nothing more than a text file.

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

fgets() add the '\n' to the end of the string if it exists in the file. So you need to strip it off before calling rename().

fgets (ipadd , 16 , pFile);
if( ipadd[strlen(ipadd)-1] == '\n')
    ipadd[strlen(ipadd)-1] = 0;
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

Increasing priority for a thread is not a good idea because it may halt all other threads, including the operating system itself.

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

what version of MS-Windows are you running? Use Windows Explorer to see if it will rename the file to that ip address.

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

The file is still open. Close it first before trying to rename it. Move line 22 up to about line 16

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

>>trytoread()
coding for that would be simplified if you pass the parameters using c++ references instead of pointers

bool trytoread(ifstream& ps,map2d& ppt)
{
   ps >> ppt.descriptor;
   if (!ps)
       return false;
   ps >> ppt.value;
   if (!ps)
       return false;
   return true;
}
while(trytoread(inStream, list[count]))
   {
       count++;
   }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

also I didn't know C++ allowed type names to start with numbers.

It doesn't :)

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

Actually, I don't think USA should be giving military aid to anyone at all. Bring all our military home from around the world and let everyone fight their own battles. We are not (or should not be) the world police. This planet got along just fine for thousands of years without the USA.

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

For MFC stuff you should get familiar with www.codeproject.com because they have hundreds of free MFC programs you can use as examples. A search for treeview got over 100 hits.

Also there are several tutorials on the net

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

loop though the word and check if it contains any non-alphabetic character. The mactor isalpha() should be handy for that

for(int i = 0; i < word.size(); i++)
{
   if( !isalpha(word[i])
   {
       // oops!
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Ok, that solved the problem :)

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

That code won't work because it is an error to cast an int pointer to a float pointer. The two objects have to be the same size, and int is not the same size as a float.

If you need to pass something with decimal places to a function then pass a pointer to a float.

void foo(float * num)
{

}

int main()
{
   float x = 0;
   foo( &x );
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

just use getlin() to get each line

#include <sstream>
//
<snip>

std::string line;
int lines = 0;
int words = 0;
while( getline( inFile, line) )
{
   lines = lines + 1;
   // now split line into words
   stringstream str(line);
   string word;
   while( str >> word)
   {
      words = words + 1;
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>You made it sound very easy. Remember that was my first time ever trying to do a program.

you said you wanted to see the final program, so I posted it, knowing that this was your first time. I remember mine too -- I was terrible at it. Keep practicing and you'll get the hang of it.

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
// This program determines the commission on real estate sales
// depending on the type of property sold.

#include <iostream>
#include <iomanip>
#include <cstd1ib>

using namespace std;

int main ()
{
  const double       RESIDENTIAL_RATE + 0.060;
  const double       MULTIDWELLING_RATE = 0.050;
  cont double         COMMERCIAL_RATE = 0.045;

int          property_code;
double    sale_price,
             commission_rate,
             commission;

cout << setprecision (2)
       << setiosflags (ios::fixed)
       << setiosflags (ios::showpoint) ;
cout << "Enter the property's selling price: ";
cin >> sale price;

cout << end1 ;
cout << "Enter the property code according to the following."
       << end1 << end1 ;
cout << "Residental,            enter R" << end1;
cout << "Multiple Dwelling,   enter M" << end1;
cout Commercial,                enter C" << end1 << end1;
cout << "Please make your selection:  :;

cin. get () ;                 // Discard the \n
property_code = cin.get () ;
//ALL YOU HAD TO DO IS REPLACE THE SWITCH STATEMENT
// LIKE I DID BELOW.
//////////////////////////////////////////////////////////////////
    if( property_code == 'R' || property_code == 'r')
    {
       commission_rate = RESIDENTAL_RATE;
    }
    else if( property_code == 'M' || property_code == 'm')
    {
        commission_rate = COMMERCIAL_RATE;

    }
    else
    {
         cout << end1 << end1
                <<"Invalid Property Code! Try Again" << end1;
         exit(1);
    }
////////////////////////////////////////////////////////////////////

    commission = sale_price * commission_rate;

    cout << end1 << end1;
    cout << "The commsiion is " << commission << end1;

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

I tried to submit the answers to the questionaire about 5 times and apparently failed each time. So I gave up.

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

The requirement was to REPLACE the case statements with if statements. Let me post a little bit better code snippet. All you have to do with the below code is to add the remaining if statements just as I did for 'R' and 'M'

if( property_code == 'R' || property_code == 'r')
{
    commission_rate = RESIDENTAL_RATE;

}
else if( property_code == 'M' || property_code == 'm')
{
     commission_rate = COMMERCIAL_RATE;
}
else ...
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

i think americas support for israel is wrong.

why? After WWI it was UK who had control of the Jewish immegration.. So I suppose today's situation is all UK's fault :)

After the end of World War II, The British Labour Party won the elections in Britain with a manifesto which included a promise to create a Jewish state in Palestine and rescind the 1939 White Paper. However the Labour Foreign Minister, Ernest Bevin, decided to persist with existing policy, due to the continued importance of cordial Anglo-Arab relations to British strategic concerns throughout the region.

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

Post what you have tried.

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

Why don't you ask your school's principal or some other teacher what you want to do and why. Does your school have any computer programming classes ? Yes, then maybe you can use one of their computers to do your work.

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

You are likely to be ignored, or written off as a loser, if you

  • cross-post to too many different newsgroups

Yup.

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

>>compare and index or argv to i.
I suspect you misunderstood your assignment.