~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Heh, maybe a feature of their "smart" and "optimizing" compiler :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

does it? At least the scenery changes. And the permutations are far larger. Weather, time, scenery, etc. etc. all modelled in quite good detail.

I bet you havent played Final Fantasy XI or World of Warcraft otherwise you wouldnt be saying this :P

I'd rather fly for real, but the cost is prohibitive.

lol

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm the line in red says: static friend foo; But as far as i know, to declare a class a friend of another, we just need friend foo; coz the qualifier static doesnt make sense in that context ( for explanation please read my prev post ).

And compiling the same eg. with the recent version of GCC MingW compiler flags the same error. Maybe static qualifier before the friend keyword are not allowed in C++ standards. :confused:

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get flamed for it. :P

I put in a rockstar.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm.. just to put you on the right path i am going to give a crude example of how it can be done using simple nested loops. Just understand the logic and implement it accordingly.

int main()
{
    int n = 0, count = 0;
    char first_char = '*', second_char = '+' ;

    cout << "Input an integer: ";
    cin >> n;

    for (count = n + 1; count > 1 ; count--)
    {
        for (int inner = count; inner > 1 ; inner--)
        {
            cout << ((inner % 2) ? second_char : first_char) ;
        }
        putchar('\n') ;
    }
}

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Now I'm back to MS FlightSim

..which again amount to the same repetitive process of flying different planes under different conditions :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hm.. Mr. Dragon, I think there is a typo mistake coz the code will not compile. And what the OP wants is "static friend function".

@Madankumar:

By static do you mean "static storage class" or "static linkage" ?
If you mean "static linkage" then friend function can be static.

As far as static storage class friend functions are concerned, you can have a class with static functions which is a friend of another class. But there is no need since friend functions can access all the variables of the given class whether static or non static

#include <iostream>
using namespace std;

class Mine
{
    public:
        string mystring ;

        Mine()
        {
            mystring = "hello" ;
            i++ ;
        }
    friend void display( ) ;

    private:
            static int i ;
};

int Mine::i = 0 ;

void display( )
{
    Mine var ;
    cout << Mine::i  << endl;
    cout << var.mystring ;
}

int main( )
{
    Mine i , j ;
    display(  ) ; // will output 3
    return 0;
}

MyOutput:

3
hello

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm... so post what you have attempted so far and I will try to see what can be done .

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

the ugly orc

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Are you sure you have got the pattern right, coz it seems a bit..weird.

If your question is related to drawing [search]pascal triangle[/search] like structure you can search for it in the code snippets section by clicking on the keyword above.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

And.. thats why most of the new languages make the pointer mechanism transparent to the user by allowing the user to ONLY pass reference variables to the functions or let the user create only reference variables which occupy on the free store rather than on the limited space of stack. Allocating the space for the var created on the stack is a pracitce generally avoided nowadays.

Examples include Java and so on where the object being passed around or a new instance variable created is a reference variable which has to be allocated space using the class constructor.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

MMORPG's rock

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

which belonged to

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

YOu get to be the boss.

I put in a super moderator.

(thanks for the explanation Mr. Darren :D)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes that and many other things to be considered like the kind of overhead introduced when you call system functions for trivial tasks.

A very good tutorial by my friend and forum member Mr. WaltP can be found here which introduces some of the things which should be avoided.
http://www.gidnetwork.com/b-61.html

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Absolutely a novel idea, a bow to who thought of it, really takes the load off us.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This is so C O O O L.

Now maybe instead of pasting the links to various reference sites or for refering to function prototypes, i will just wrap the function name in tag attributes.

For eg. Miss Dani if you anytime plan on learning how to accept user input in the string format, you should look up the [search]fgets[/search] function. (hehe)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

One bug in your program, when the user enters x and y coordinate where he wants to put his number, you dont check to see if those coordinates are within bound (i.e. a < 9 and a > 0) and the same with b. This may allow user to write at a location which doesnt belong to him.

Also you dont check whether the number entered by the user lies in the range of 1 to 9. Perform all the bound checks properly to ensure that your program doesnt crash and perform in unexpected manner.

The check function can be something simple like: (have not checked the function, just my logic)

{
    int index = 1 ;
    for( index = 1; index <= 9; ++index ) {
        if( matrix[row][index] == value_entered ) {
            if( index == col ) {
                continue ;
            }
            else {
                printf( "The value is already present" ) ;
                return 0 ; // return false, condtition not satisfied
            }
        }
    }

    for( index = 1; index <= 9; ++index ) {
        if( matrix[index][col] == value_entered ) {
            if( index == row ) {
                continue ;
            }
            else {
                printf( "The value is already present" ) ;
                return 0 ; // return false, condtition not satisfied
            }
        }
    }

    return 1 ; // value not present already, so continue adding the new value to matrix
}

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

run the in a command prompt then ull be able to see all the output before it quits. or try placing system("PAUSE") before the return statement, but i think thats bad practise to do that

Correct .
Its bad practice to use system calls to achieve such a trivial function.
Better use getchar() if using C and cin.get() when using C++.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yep, its working now.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm just wanted to tell you Miss Dani that when i click on the search tag word "search" no new window opens up, nothing loads in the page itself. I have to use the option "open in a new tab" to come up with the result page.

I am using Mozilla Firefox 1.5.0.7 on Win XP Pro.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The correct way of using fgets is fgets( char*, size_t, file_stream ).
Since you pulling the user response from the std input stream ie the keyboard, you have to put stdin in place of fr since the stream under consideration is the std input and not the file stream.

Also have made some changes in your code where it was not correct.
The changes i made are marked in red.

#include <stdio.h>

int main()
{
    char s[BUFSIZ] = {'\0'} ;
    printf("Enter the filename to open: ");
    FILE *fr = 0;
    fgets(s, BUFSIZ, stdin);
    fr = fopen(s, "w");

    if (!fr)
        return 1;

    while ( fgets(s,BUFSIZ, fr) != NULL)
        fprintf(fr,"%s\n", s);

    fclose(fr);
    return 0;
}

In case you need the function prototype or reference to any standard C function to see if you are making use of the function in a correct manner, you can visit here.

For some file handling tuts visit here:
http://www.cprogramming.com/tutorial/cfileio.html

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm so can we expect the feature in near future or is the idea dead ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hey Miss Dani, i was just wondering if it would be possible for you to add the functionality of keeping the buttons "Warp Iilinetags", "warp code tags" to the Quick reply WYSIWYG editor, since it has some extra space or unused space at the right corner.

Those are the basic features which everyone needs even when someone is quick replying to a thread and just to use them i have to switch to the advanced view when the entire job can be very well done in the basic view.

Please let me know if you can ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

And along with the above code provided by Mr. Dragon, you might want to use fgets( char* my_array, SIZEOFARRAY, stdin ) to accept input from the user and a function which searches the entire structure array for the given string and then returns its state equivalent.

But personally i would advice you to go with the associative array or the STL map construct, unless you have been instructed not to do so, since it makes the code less cluttered, more logical and extensible. One thing you would never want to do in programming is to reinvent the wheel.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm maybe you need to look up on associative arrays HERE
But with your sparse knowledge of C++....

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

girlfriend, who has

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I forgot one detail...I can use cin on numeric data, but i cannot use it on text (except in main()) Scratch the above...I can use cin just not cin.get...why?

1 Some code:
/* Though my book is out-dated my compiler is new (Bloodshed 4.9.9.2, and i am running on a Windows 98 OS if that has any part in my misfortune. */

#include <iostream>
    #include <cstdlib> //What does this header do? LOOK HERE
    #include <iomanip.h> no .h is not needed
 
    using namespace std; //construct in C++ to avoid name clashes and 
                                    // to organize modules in a logical way 
 
    void TestCin(/*What goes here and why?*/);

    int main(int argc, char *argv[]) 
// argc - number of command line arguments
// agrv - array of char pointers -- basically array of C strings which
// are used to store the parameters supplied at teh command line
    {
        char TestCharGet[21];//Create TestCharGet as a character array
        cout << "Test the cin command\n";//output info
        cin >> TestCharGet;//Get TestCharGet
        cout << "\n" << TestCharGet << "\n";//output input
        system("pause"); // dont use non portable like this one
                                  // instead use getchar() for the same thing
        TestCin();
    }
 
    void TestCin()
    {
         system("cls"); // dont use non standard functions which make
                              // your code non portable

          char Toop[21]; 

         cout << "does it work\n";

         cin.get(Toop,21); // cin >> toop not safe ssince no bound
                                  //  check. You overwrite the mem that
                                 // doesnt belong to you

         // if you using C++ better use string instead of char …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

along with a

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Even you get a better game coz i have made game in Irrlicht :D

I put in some Transistors.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

So, if I want to test some program from the command-line, should I always include for example like this part in my program?

int main( int argc, char * argv[])
a = atof ( argv [1] ); b = atof ( argv [2] );

Those things are included there becoz whatever we accept from the command is passed to the program in the form of char* (old C style strings) -- thats why the main() prototype contains char* argv[] which means argv is an array of char* or C style strings. atof is used since what we want to do is add two floating point values but they are supplied by the user in String format -- so we need to convert from string to float so that they can be added in a natural way.

And also in your explanation, you put -f filename.txt . This is text filename. What I did is just put filename and 2 numbers (add 100 200), and that files extension is .exe. I tried to use text file which I simply typed add 100 200 in the note pad and saved it with the extension .txt and put that file name in the command-line. Then what is does is just to open that file...... ( I know its stupid...)

The filename specified at the command line is also accepted by the prog as C style string. So inorder to make use of the data present in the file, you need to open …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Factorial values may easily go out of hand and overflow due to their exponential nature. So if you insert very high values of "n" the output might overflow.

Please paste your output along with the input you giving, along with the function combination def. (just in case).

Also dont use system("pause") to stop the screen. Use getchar() to achieve the same function.

Long values are printed using the format specifier %ld which i dont see in your program.

Nothing more can be said unless you post your combination function along with the input which you supplied to it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Dont ressurect old threads like you were some shaman.
Thread closed.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Download python from this site. It is one of the distributors of Python which bundles alll the files and features in a single package, taking care of setting up all the paths for you.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Don't know about everyone else; I never use the forum jump buttons, mainly because it's too far down on the page, and mainly because I don't think of it.

Yes, now that you mention it, even i have never used it. Too far down the page. I prefer using drop down menus, they are the best.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That I think is "Icelandic" secret... not to be told to anyone else coz if need arises then... i hope you get the point :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

He means that it is good you think that practice makes a man perfect. Dont get him wrong, he is just trying to help you out.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ok so how should we say "Hello there, my name is ...." in Icelandic

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Na.. he is afraid that his friends might stumble across this same snippet while reasearhcing and submit the same as assignment.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

cin.get() in case of c++ and getchar() for C

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Come on now,

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Actually it depends...

Mr. WaltP's point of view is based on portable coding practices and using the standard functions so that the code can run irrespective of the machine.
Mr. Dragon's point of view is based on a better implementation for a single platform.

So you can chose your pick, keeping in mind the issues associated with each of them.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

YOu can refer this code for reference and start off with your assignment with ease. Also for explanation look HERE.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

aw ok !
is this the right conversion from int double to void ?!
... = * (int *) ...;
...= * (double*)...;

Dont get what you are trying to say, quote an eg.

the hardest part is enum hahah lol how i'm gonna convert from sex to void* heheh thats pretty hard ! coz i faced alota of difficulties printing the sex struct...

*hint* enum values are in the end integer values.
male = 0, female = 1

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

IF thats the case then maybe you need the void* layer and not void* layer[100] . This way you can make layer point to any type of structure instance or any primitive data type var as you want.

And done that, you cant just print out the name of the structure instance. YOu need to write a custom function like you did back in the " qsort() " function probably a " display() " function.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm i dont know what you are up to becoz sifting through your code i found this:void *layer[100]

What are you trying to achieve here? Do you know what it stands for?
It stands for layer as an array of 100 void pointers ?
Is that what you wanted ?

And please post the code with all the formatting and removing the commenting. It really is a big problem trying to find something suspicious from that code dump.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
...
void* pop(void) {return layer[100];} // replace with "return layer"
...
name[1].push(student[0].fname);
printf("%s",name[1].pop());

thank you

layer[100] stands for the character at position 99 and not the entire C Style array pointer. So what you are returning is the value of the 99th character as an addr of the string which is wrong.

Make the changes and tell me whether it works.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
if(rom=='IV' || rom=='iv')
{
  tot=tot+4;
}

That ain't character comparision. 'iv' is not counted as a character. A character implies "only one character" so you end up comparing only the first character i.e. 'i' in your case. Try using string comparision functions like strcmp() .

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What exactly is your problem, compilation error, runtime error ?
Post your errors or detail the things which occur when you run your code.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

..write to multiple file's instead of just the one..

Create multiple file streams, and what you are doign to one file, make that applicable to multiple files.. simple.

FILE *output1; 
FILE* output2;
FILE* output3; // ......
 
// do something with these files
 
// close the above files