WolfPack 491 Posting Virtuoso Team Colleague

What is a convolution program?

WolfPack 491 Posting Virtuoso Team Colleague

Try this:

cin.getline(playerOne.c_str(), 21);

This will not work. c_str() returns a constant pointer to the character array. You can't change it.

WolfPack 491 Posting Virtuoso Team Colleague
class JarType 
{
public:
    friend JarType operator+(const JarType&,const int);

  private:
     int  numUnits;
};

JarType operator+(const JarType& right,const int add)
{
    return JarType( right.numUnits + add);
}

You should change the way you comment and the way you name your member functions. For example do not leave a space between the double semilcolon and the member functions.

JarType:: JarType
JarType::JarType

Maybe having a look at this would help.

WolfPack 491 Posting Virtuoso Team Colleague

Don't you think such a member-modifying feature should be added to C++?

No.

WolfPack 491 Posting Virtuoso Team Colleague

How about declaring x as a [search=1911904612]static member[/search] of class point?

WolfPack 491 Posting Virtuoso Team Colleague

You got a problem with this code?

WolfPack 491 Posting Virtuoso Team Colleague

I haven't looked at any GTK code. But the main reason for using a pointer maybe that the structure is too large or a lot of instances of that structure is created. By using a pointer, you can create the instance in the heap memory, rather than the limited stack memory. Also, when you pass data around, passing only the pointer saves memory rather than passing the whole variable.

WolfPack 491 Posting Virtuoso Team Colleague

There are too many compile errors to be counted.
For example

void getdownPayment(float& downPayment)[B]; // you dont need this semicolon[/B]
{

There are a lot of functions that have similar errors.

Also it looks as if you are not saving the file in ASCII format. Best thing is to copy and paste the code to notepad and overwrite your original source file using notepad save as. That should rid you of the unwanted unicode characters.
Your compiler outputs the line numbers where the compile errors occur. Go to those lines and correct them yourself.
Properly indent the code. I see some mismatched braces and brackets. you can catch those by properly indenting code.

WolfPack 491 Posting Virtuoso Team Colleague

oh my god. I have seen some pretty badly formatted posts, but this surely takes the cake for the worst. I am sure nobody will take a second glance at this post unless you use

tags and re-post properly formatted code.

WolfPack 491 Posting Virtuoso Team Colleague

Indent your code properly.
Just telling the program won't give you the result doesn't help. Tell us what you expect and what the program gives actually.

void SortList::QuickSort(int X,int I)
{
int L,R,V;
if (I>X)
{
V=list[[B]i[/B]];[B]// what is this simple i? I don't see it declared anywhere.[/B]
L=X-1;
R=I;
for(;;)
{
while(list[++L]>V);
while(list[--R]<V);
if (L==R) break;
Swap(L,R);

}

repost your properly indented code with the above correction and a better explaination of the problem.

WolfPack 491 Posting Virtuoso Team Colleague

ah. This opens a lot of [search=1287457368]windows[/search] of oppotunities. nice nice.
*dreams up a lot of possible uses*

WolfPack 491 Posting Virtuoso Team Colleague

"One man's meat is another man's poison."

Well put.

WolfPack 491 Posting Virtuoso Team Colleague

Some of the corrected errors are

void AddWords( char text[30]) // you are not returning anything, so use void.
{
    newNode=getmem();
    strncpy(newNode->words,text, 29); // you can't just assign character arrays. Use strncpy to copy the contents.
    newNode->next=head;
    head=newNode;
};

Also once you are finished with the program, free the memory used in the list, or you will be leaking memory.

WolfPack 491 Posting Virtuoso Team Colleague

It is antics like these that make me feel bad about using firefox in the first place. I feel as if I am somehow a pawn in these petty browser wars. Thank god ie7 is available at last. :)

WolfPack 491 Posting Virtuoso Team Colleague

We don't do homework. If you post code which you have written upto now, and say where you are having the problems, we will help.

WolfPack 491 Posting Virtuoso Team Colleague
WolfPack 491 Posting Virtuoso Team Colleague

Oops. I forgot to tell you that we don't delete threads unless they are violating forum rules.:)

Edit.
I am closing this thread before it get's out of hand. But before that I should explain the reason for not deleting this or any other thread (incase other requests similar to this arise in the future). If you have any other questions, please contact me via PM.

  1. The reason we offer free public help rather than private paid help is for newbies, like me and you, to learn from other people's mistakes and the solutions they came up with. If a thread gets deleted once it gets solved, that objective will not be achieved, and all the free, selfless, helpful effort put by the solution provider will be in vain. This is like open source. The more you share, the more you benefit in the whole.
  2. Deleting a thread deletes all the replies contained in it, along with the original posting. This discourages the helpful people from posting again, because they do not have a guarantee that their post will survive for others to learn.
  3. Daniweb holds a copyright for all the threads posted in this site. So after posting something, it is not your property but rather Daniweb's.

There are a lot more reasons that I can think of, but the above three should be the most important.

WolfPack 491 Posting Virtuoso Team Colleague

The best thing for you to do is to design a command line argument handling program by yourself. Maybe you will find one in the exercises of your book. If you find one, do it and post it here with the question for us to check. If you can't find one tell me and I will give you an exercise :)

WolfPack 491 Posting Virtuoso Team Colleague

why would people want to google for you?

WolfPack 491 Posting Virtuoso Team Colleague

It is used when you want to control your program from the command line. Rather than promting the user for input, say for example entering a filename, you can use a switch like -f filename.txt and that will be all the program needs for execution. The command line arguments are particularly useful for automated testing. If you have a lot of inputs to test, you can't always enter them by hand. So you can create a bash or dos script that creates the appropriate commandline for each input and run the program by passing those arguments.

WolfPack 491 Posting Virtuoso Team Colleague

This site existed from some time back. Some member (I don't remember who) had that site in his signature too.

I feel pity for Microsoft :) .

I don't see why. Does firefox have to rely on users looking to download Internet Explorer 7 to propogate itself :)?

WolfPack 491 Posting Virtuoso Team Colleague

MOD - Please remove this thread. It is indexed on google and do not wish for it to be viewable any longer.

Why?

WolfPack 491 Posting Virtuoso Team Colleague
#include <iostream>
#include <fstream>
// #include <string> you are not using strings so no need for this.
using namespace std;


int main( )
{
    
   // Open the file
   ifstream theFile("grades.txt");
   
       if (theFile.good( ) )
   {
    int number = 0; // always initialize the variables
    double average = 0.0 ; // always initialize the variables
    int score = 0;
    int count = 0;
    int max = 0;
    int min = 0;
    while (theFile >> number )
    {    
         if ( count == 0 )
        {
              max = number;
              min = number;
        }
        else
        {
              if (number > max)
                   max = number;
              if (number < min)
                   min = number;
        }
         score += number;
        count++;
    }
    
    
    if ( count ) // just in case that there was nothing in the file
             average = score / count;
    
  // print the results
       cout << "The values were " << " Avg: " << average << " High: " << max  << " Low: " << min  << endl;
        
         
      
   }
   else
   {
       cout << "\nCould not open the file...\n";
    
   }
   theFile.close();
   // system("PAUSE");// bad practice. use something else like 
   cout << "press enter to continue...";
   cin.get();
    return 0;
}
WolfPack 491 Posting Virtuoso Team Colleague
while (theFile >> number )
    {    
        for (count == 0; count < 100; count++)
        score += number;
        
        //count++;
        if (number > max)
            max = number;
        if (number < min)
            min = number;

I mean the whole code.

WolfPack 491 Posting Virtuoso Team Colleague

post code.

WolfPack 491 Posting Virtuoso Team Colleague

Declare max , min , count , score and avg out of the loop. Set the values for those inside the loop. After that output the values after exiting the loop.

WolfPack 491 Posting Virtuoso Team Colleague
int max = 0; // If negative numbers are allowed set this to the first number you read (i.e. when count == 0 )
        int min = 0; // Set this to the first number you read(i.e. when count == 0 ). Otherwise you may always get 0 as the min. 
        score += number;
        count++;
        if (number> max)
            max = number;
        if (number< min)
            min = number;
WolfPack 491 Posting Virtuoso Team Colleague

You can use a loop to go through all the numbers in the file.
something like this.

int number;
int score = 0;
int count = 0;
while ( theFile >> number )
{
     score += number;
     count++;
}
average = score / count;

figure out how to find max yourself :).

WolfPack 491 Posting Virtuoso Team Colleague

Do you have to calculate the averages line by line? or only once for all the numbers in the file?

WolfPack 491 Posting Virtuoso Team Colleague

ooh. Silly me. :cheesy:

WolfPack 491 Posting Virtuoso Team Colleague

Its sad thinking he thought this was his only way out!

:(

Wasn't he trying to get in?

WolfPack 491 Posting Virtuoso Team Colleague

Do I have to go through a for loop and delete each character individually?

No. Just calling delete pointer_variable should suffice. The destructor of class string should handle the rest. If you are trying to delete an array of string pointers, use delete []array_name; Another thing is make sure that you are trying to delete a pointer and not a normal variable.

Can you post the declaration of your class, and it's constructor?

WolfPack 491 Posting Virtuoso Team Colleague

A. The header file for standard winsock use

include <winsock.h> and link with ws2_32.lib

B. a helpfull tutorial on basic winsock client/listen string transfer? Help is much appreciated, thankyou.

Jhonny's Tutorial
Beej's Guide

WolfPack 491 Posting Virtuoso Team Colleague

Surely a memory leak. delete the pointer to the table once you are done using it. Are you calling the above code inside a loop?

WolfPack 491 Posting Virtuoso Team Colleague
#include <stdio.h> // There should be no spaces between # and include
#include <stdlib.h>
int main (void)
{
    int n = 9; // initialize n to the value you want
    for (int i=0; i<n; i++) // deleted the semicolon
    {
        // You print spaces until n - 1 - i
        for (int j=0; j<n-1-i; j++) // deleted the semicolon
            printf (" ");
        // After printing spaces print * until n
        for (int k=n-1-i; k<n;k++)
            printf ("* ");
        printf ("\n");
    }
 
    system ("PAUSE"); // use cin.get() or something
    return 0;
}
WolfPack 491 Posting Virtuoso Team Colleague

I don't see how we can use it in a reply to a technical question. From what I have noticed, it just takes us to the blog list with keyword [tag]google[/tag], and it is the responsibility of the reader to filter out what he needs. That rather doesnt achieve what we look for in a reply to a question. We have to be exact in our replies, or it will be no different from doing a [tag]google[/tag] search. The feature is cool, only I don't see how to integrate it constructively within our posts and not just for the sake that it is there.

WolfPack 491 Posting Virtuoso Team Colleague

the thief was taking 1 gr from each trinket

You didn't tell this initially. We all thought that the cheat could steal only from his trinket. So the total was always 1 gram less than 55 oz. :eek:

WolfPack 491 Posting Virtuoso Team Colleague

Sorry. We don't do homework :)

Salem commented: Absolutely! - Salem +3
WolfPack 491 Posting Virtuoso Team Colleague

Suppose I have created a class new with arguments.

You can't do this. new is a C++ keyword. You can't create classes or variables with keywords as names.

I have declared this as object new1 in the main.
new new1(arguments). Now what should i do if i want to change the values of new1 object's arguments.

If the data members are public, you can change them directly. If they are private you will have to write set functions that set the data member values.

If you don't understand my reply, go read a C++ tutorial on classes.

WolfPack 491 Posting Virtuoso Team Colleague

Maybe Visual C++ allows objects of classes without data members to be declared const even when a constructor is not defined. Because there are no data members, there is no data to be initialized so there is nothing wrong with it. But VC gives a warning when objects of classes with data members are declared const without a proper constructor.

On the other hand g++ apparently doesnt give any room whether the class has data members or not.

I would quote the apporoprite portion of the C++ standard to find what it has to say about this, but I am a bit pressed for time.

WolfPack 491 Posting Virtuoso Team Colleague

My question is, doesn't compiler provide the default constructor when we declare an object of type const?

There is no such limitation. The above code compiles under Visual Studio 2003.

PS.
But if you have a data member in the class, things should be different. That is because if you are not initializing data while creating the object, you can't change any of it later.

WolfPack 491 Posting Virtuoso Team Colleague

Yep. The results were mailed to my account, and no trouble from ads too. But looks like I overestimated myself. :p
Aptitude 1: Spatial skills 10/10
Aptitude 2: Verbal ability 9/10
Aptitude 3: Abstract reasoning 8/10
Aptitude 4: Numerical ability 8/10
Aptitude 5: Mechanical ability 7/10
organizational abilities 10/10 (These fellows should see my room or table)

WolfPack 491 Posting Virtuoso Team Colleague

Try the ShellExecute API.

WolfPack 491 Posting Virtuoso Team Colleague

I got spatial too. But I am sure I got all but one correct. How do you get the results?

WolfPack 491 Posting Virtuoso Team Colleague

Take the kettle off the stove.

WolfPack 491 Posting Virtuoso Team Colleague

Just use the replace method of the C++ string class.
Something like this perhaps.

#include <iostream>
#include <string>

int main()
{
    std::string email("abcdefgh@abcd.com");
    std::cout << email << std::endl;
    email.replace( email.find('@'),1, "AT" );
    std::cout << email << std::endl;

    return 0;
}

One thing to note is that only the first @ character will be replaced by this method. But I think a string with multiple @ characters is not a valid email address.

WolfPack 491 Posting Virtuoso Team Colleague

Err... Wolfie, i had the same impression at the start that this is all about syntax highlighting in code but this is not about it. This topic is about using code to highlight the text if the context demands as Mr. Dave Sinkula had pointed out.

The thing about code highlighting is what Miss Dani has been thinking about, but is not on her top priority list.

I know what this thread is about. If you look at my previous posts you will realize that. Since colour has been re-enabled in the reply boxes, I will have to assume that what darren refers to is the syntax highlighted code blocks. If dani says that colour enabled code will be implemented in the future I don't have a problem. After all these things take time. But if anybody questions the effectiveness of using colour within posts or code blocks, that is where I will have to counter-reply ;).

WolfPack 491 Posting Virtuoso Team Colleague

sorry, but i would have to agree with dani though, it does look so much better in one colour

That means you don't use a code editor with syntax highlighting, and would rather use notepad to write your code? Or are you a programmer at all?

WolfPack 491 Posting Virtuoso Team Colleague

Or maybe when there hasn't been posted in an thread for over 10 days red text appears above the reply button "Do you know that there haven't been posted in this thread for over 10 days?"

I think that might help (Maybe to for thread bumping in general)

Once a thread has been marked solved, a similar message appears above the quick reply box.

WolfPack 491 Posting Virtuoso Team Colleague

Not many newbies bump a thread to say thanks. When something like that occurs it is up to the moderators to educate the users (usually by deleting the unwanted post and giving the reason-this sents an automatic PM telling the user about their offence). Once they get to know that thread bumping is not good, they usually don't do it again. Trying to cripple users by enforcing little things like that only clutters the webpage.