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

Okay the thing is that while generating random numbers care has to be taken that the numbers so generated dont repeat in a pattern or frequently (though this would happen if the range is small).

To safeguard from this, normally all random generators make use of a base values (normally a very large number) which serves as a base or as a reference so that the numbers so generated using them dont repeat.

This said, care should be taken that the reference number should be as unique as possible and should not be ideally repeated.

The time( ) function returns the number of seconds that have passed since 00:00:00 GMT January 1, 1970. So when this value is passsed to the time function, it serves as a satisfactory reandom number generator reference or seed value as they call it.

More information here.

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

word cup -> universal saucer ;)

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

He commands his

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

I see in your code that you are not using srand( ) to seed or to initialize your random function and hence you are getting repetitive values.

Try putting srand( time(NULL) ) at the start of your code and then see. For more description see here.

HOpe it helped, bye.

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

Yeah...even we waiting for that kind of change for long..
and all we have got is Miss Dani :D

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

....did I just say that out loud?

*sigh* you busted my chance of getting Vista from Blud by saying out something loud and now this...:mrgreen:

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

Twice so far you said it was a bad idea. I am still waiting to hear your reasoning why. I can't listen if you don't tell

Maybe because he hates games ?
Maybe because he didnt get to defeat the final villian of Warcraft or didnt get to finish off the final boss of Half Life 2.

:cheesy::cheesy::cheesy:

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

The examples in that previous thread use additional variables/functions to do the job. The OP wants to remove the character without using additional variables or functions.

Does my this solution use more than one variable ?

void remove_s( char tmp[] )
{
    while( *tmp != '\0' )
    {
        if( *tmp == 's' || *tmp == 'S' )
        {
            memmove( tmp, tmp + 1, &tmp[strlen( tmp )] - tmp ) ;
        }
        else
        {
            tmp++ ;
        }
    }
}

I guess I will leave it to someone else to solve his problem since I really dont understand what he is asking for.

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

But where is the code which you attempted and which is not working...

Paste it here and let me have a look at your own function.

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

First things first...post your code in code tags as the background image in which you write your post says. Read the forum announcements for more details.

Dont use void main( void ). This is the wrong defination of main( ) . It actually is int main( ).

Post the specifications -- ie the compiler and the OS you are using.

Post the code which you have in your function.

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

Yes, I think its the only thing which will give you peace of mind...will help you in pinpointing the exact cause of error( hardware or software ).

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

Hey buddy Geeks lounge is for chilling out. You should post your question in appropriate forum to get quick help.
.

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

Hmm.. I am from India and interested in all the tech things..
.

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

Depends -- never is fixed.

Normal hours are from 3 AM to 7 AM.

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

Hi all,

Just wonedering how many other girls are here?

I think there are a lot, but not many of them are core or regular members so you wont get to see many around here..but yeah if you stick around for some time you can find many of them here..

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

Doesnt this post solve your problem ?
.

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

take this *TISH* and yea i am a "software engineer"

Whoa...glad I am friends with this girly, already have got a lot of those *TISH* and *BASH*...;)

One of these days Dani, you will find that the web page is not wide enough to accomodate your stars.

*sigh* I should just cosider myself happy since my name is present on the first page of member list when sorted by posts ;)

As far as having a game forum, sure. As for helping, no knowledge.

I know you would rock even there...:cool:

:(

Ah....looks like Joeprogrammer is really desperate to get a gaming forum and so am I...

Hi Nick,
I think that a Gaming Development and a potential Embedded Development forum are good first starts to moving away from the homework questions and more towards the professional industry.

Bingo....happy to see you are getting the point we were trying to prove..:cheesy:

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

You mean like getch?

getch is a non standard function.

As far as getting character without enter is concerned, it cant be achieved in standard C. Try looking at your compiler documentation for more support.
.

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

Ah excellent my friend..

Now only we have to wait for Miss Dani to notice this thread..;)

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

You need to escape the \ character since the it is seen by the compiler as the language construct.

You can do something like: sprintf( acFilename, "c:\\a%d.txt", count ) ; Use \ to escape the special \ character. In C and C++ \ is the escape character used to escape some special characters like ", ' and so on..

Also I think it is not a good practice to use \\ since its not portable. If possible try using sprintf( acFilename, "c:/a%d.txt", count ) ; which is a much better way to do things the right way.;)

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

Hey there buddy, welcome to Daniweb.

Good to see that even you play good games like WOW and F.E.A.R.
:D

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

Please use code tags while posting code since it preserves fomatting and makes the code more readable by syntactic highlighting..

Read the forum annoucements for more details..

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

whoops...did I say that out loud?

Grr...yes you did ;)

*sigh* looks like will have to think of some way to make him cough up his precious Vista copy...

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

There are a few things you can try out. For eg. you can accept everything as string from the user and parse it to get out the data which you require using [search]sscanf( )[/search]

int main( )
{
    char buffer[BUFSIZ] = { '\0' } ;
    char name[8] = { '\0' } ;
    fgets( buffer, BUFSIZ, stdin ) ;
    sscanf( buffer, "%s", name ) ;
    printf( "The name is %s", name ) ;
    getchar( ) ;
}

Of if you still want to use scanf( ) and write programs that way you can just put getchar( ) after each scanf( ) to take care of the stray '\n'.

int i = 0 ;
char name[10] ;
scanf( "%d", &i ) ;
getchar( ) ;
scanf( "%s", name ) ;
getchar( ) ;

Hope it helped, bye.

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

Something like this...

.

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

Hmmm...have heard that some generous and kind person who goes by the name of Blud is giving out free copies of Vista.

Hey there buddy, how are you, hope you are doing fine...nowwww, where is my copy of Vista ;)

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

Always post your code in code tags, read the forum announcements for more details.

As far as the problem is concerned, dont know what exactly are you trying to achieve here. You are struggling with your syntax. Here, I will give you a prototype of how your program should look like:

#include <iostream> // .h format of header declaration is depreceated
#include <string>
using namespace std ; // use this new way of declaring headers

void xcopy( char* destination, const char* source )
{
   //your function here
}

int main( ) // the correct way of using main( )
{
    // declare and initialize variables
   // accept input from user
   // call the function
   // display the result
}

Just to let you know that you have forgot the closing brace of your function and are getting your syntax all wrong.

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

Here Sharky this is in return for all the goody YouTube links you have given me..this is one of the best.

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

Be specific so that we can move your question in the appropriate forum...

BTW welcome to Daniweb.

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

Wow, I don't want to know the size of insects in India... :mrgreen:

Maybe you should just invest in an electronic fly swatter.

Naa...it wouldn't be fair. Me with an electronic swatter and they with their pathetic needles...

Also it takes away all the fun and I dont get to kill my mind during studying..

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

*sigh* people nowadays demand so much...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void remove_s( char tmp[] )
{
    while( *tmp != '\0' )
    {
        if( *tmp == 's' || *tmp == 'S' )
        {
            memmove( tmp, tmp + 1, &tmp[strlen( tmp )] - tmp ) ;
        }
        else
        {
            tmp++ ;
        }
    }
}

int main( )
{
    char* tmp = 0 ;
    char str[] = "Ass is an ass and nothing but ass, so be solemn" ;
    printf( "\nActual string: %s", str ) ;
    remove_s( str ) ;
    printf( "\nNew string: %s", str ) ;
    getchar( ) ;

    return 0 ;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Drats..you got me cornered :D

<guffaw>

What does this mean ?

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

Yes-- better career choice(s) (or, also, Jet Propulsion Lab, Department of Defense, or Skunkworks)

No, not working at Google. PhD at Stanford and then working at White Sands or Los Alamos is more like it.

Thanks for letting me know that such Organizations existed..have heard about them for the first time.;)

Looks like Mr. Jwenting works at one of these places...:cheesy:

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

Okay, how about doing a PhD at the Stanford university and then working at Google ? ;)

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

Just for the record, it seems that the wombat army is rapidly advancing..;)

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

the "this" keyword is a pointer to the class in which it's used. For example:

this->idNum

Is referring to the idNum data of the class your writing for.

So to answer your question, yes you would only need the "this" keyword if your working with pointers because it is essentially a pointer. It's the pointer of a class pointing to itself, if that makes any sense to you.

Looks like you are using the words class and object interchangeably.

Correction:

The this pointer is a pointer accessible only within the nonstatic member functions of a class, struct, or union type. It points to the object for which the member function is called. Static member functions do not have a this pointer.

An object's this pointer is not part of the object itself; it is not reflected in the result of a sizeof statement on the object. Instead, when a nonstatic member function is called for an object, the address of the object is passed by the compiler as a hidden argument to the function.

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

How about something like:

void remove_s( char str[], char* tmp )
{
    tmp = str ;
    while( *tmp != '\0' )
    {
        if( *tmp == 's' || *tmp == 'S' )
        {
            memmove( tmp, tmp + 1, &str[strlen( str )] - tmp ) ;
        }
        else
        {
            tmp++ ;
        }
    }
}

int main( )
{
    char* tmp = 0 ;
    char str[] = "Asses are asses and nothing but asses" ;
    printf( "\nActual string: %s", str ) ;
    remove_s( str, tmp ) ;
    printf( "\nNew string: %s", str ) ;
    getchar( ) ;

    return 0 ;
}

And btw...it was not at all interesting..;)

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

Haven't we all done a lot of geeky things already...;)

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

And because of this, the Game Development Board would IMO be geared not to 'coding problems' but higher level 'gaming concepts', whereas "I need help on my TicTacToe homework" is a C/C++ problem.

Of course, this will cause some consternation in new posters when they do need help with their TicTacToe homework because, as we all know, new useres rarely read anything except the title of a forum and rarely read all the way to the description.

Err..so are you with us?

Find me 10 existing threads (ie in the C++ forum) that could be used to seed a new forum.

So go off ... find me those 10 threads, and I will be more than happy to use them to populate a new Game Development forum.

There you go joeprogrammer, your challenge has been set

Wont be a problem for Mr. Joeprogrammer to drag some of his friends to seed the forums with questions while I myself and the others answer them out. Would that count as 10 :twisted:

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

Do you think if we handed code to every single person that was having trouble, they would study it?

Which do you think will help them remember better: if they've spent agnoizing hours on it until someone finally explains it and it makes sense, or if they've just been dumped a pile of code and said "here, have fun"?

Programming boils down to 2 things: experience and discipline.

Also, coding experience helps you prevent errors from happening, as you get into a routine of placing a semicolon at the end of each statement, etc, etc.

Coding books are not made entirely out of code; they have text to explain what the code does.

Ah..what a thing to say...couldn't have put it better. Kudos to you ;)

Being a teacher, you too should know that a lot of teachers teaching the same subject have different methods. Same syllabus, different ways of communicating. Imagine if you never gave any code in the class, just teached theory and told the students to go out and google "linked lists"..

Have you ever seen Mr. WaltP's replies or the answers he gives to people? Probably not. Because if you had, you would have know that he always gives the links and the algorithm which can be used to solve the problem, guides them step by step and helps in the way which helps in developing their programming sense.

Dont you ever wonder why the people at Google Groups( one of the finest C++ …

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

*sigh*

Maybe time will teach you or tell you the reason why the professionals are not in favor of posting entire solutions.

And just one more thing which I picked from the google groups:
"Anyone can write a program, but to help somone in understanding a program is what makes a real programmer"

Try to walk through the newbies and then you will realize how difficult it is.

Anyways I havent got anything more to say. Glad you replied.

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

Too late- my plan for World Wombat Domination is already well and smoothly underway..... MUUUUAAAAAHAHAHAHA!!!!!!!

Err..count me in.

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

My concerns ...

Which forum would someone coding a game in C++ post?
Is it wise to create a development forum that is a mixture of all programming languages?

Game development isn't just about code in C and C++, it involves a lot of issues -- Artificial Intelligence Algorithms (generic algos), Game Play Ideas( like D & D RPG's ), Pathfinding related things, Talk about OpenGL and DirectX, etc. etc. (many others)

Concept wise Game developement is generic. Also it has come to my attention that some core members( Joeprogrammer, Mattevans, Niek etc.) are into game development courses and of course even I have done some work in that area (though not any more).

Of coure I understand the situation you are in right now, so I would just leave it to you to decide or think about this at your own leisure...

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

*sigh* Hey there May4life I know what I am saying is not officially according to the Daniweb rules but you are spoiling the newbies.

Just handing them readymade solutions will stunt their development in these things, they would never think of doing things their own, will always expect an easy answer, and much more.

Can't you atleast let these people have a shot of it....

We have already been there with you (I suppose a PM was sent to you) but still you must think that the thing "hope it helped" isn't helping them but just harming them in an irreversible way.

Hope you understand the point I am trying to prove..

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

I never cheated because cheating here is a give and take procedure and I had nothing to give except blank stares...duh..

The way I start off:

1. Pick up the book (of couse this is important).

2. Read about the author and his achievements and of course the abstract of the chapter.

3. See that a mosquito or fly is bothering me.

4. Swat it with my book (thats why book is so imp)

5. Bring up my Biology set and start dissecting it, and this takes really a lot of concentration.

6. The friends of the mosquitos / fly I just killed come to take revenge.

7. A very fiery battle starts and after fighting like real warrior, I end up winning the battle.

8. All this takes up a lot of enery and effort, so I get up to take some rest.

9. Since mosquitos and flies are in ample I get stuck in recursion and never get to study.

*sigh*

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

So is the Game Development forum under consideration...

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

But still we can surely aim for a "game development" message board, can't we guys....;)

I voted "no" in support of a Games forum, but the first thing I thought of when I saw this thread was a Game Development forum.

I've been noticing lately that there's no such forum, and it's been bothering me. A Game Development forum would attract lots of discussion about OpenGL, DirectX, and complex 3D math, which is good. One negative consequence of a Game Development forum would be that gamers still would post gaming questions in this forum, which would create more of a load for the moderation staff. But that would be a lot better than a Games forum, which like Dani said, would attract a lot of kiddies and chatroom speak.

After all, isn't the purpose of this site to be a "IT discussion community"? I don't think playing games counts as IT, but creating them certainly does.

I even voiced the same opinion..

But Miss Dani is afraid that there are not too many professionals to handle the forum -- after all there has to be a forum leader.

But who knows, having that kinda forum might attract some pros and we would really set the thing rolling..

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

dark murderous intent.

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

The speed of todays RAM -- mine is 2.5 Gz

Speed of RAM....2.5 GHz ?
I thought it was still in MHz ;)
The latest one is I think 333 MHz. Maybe you wanted to say Processor speed.

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

Actually too many minor things, but I will point out some to you...

using namespace std;
This adds the standard library of C++ commands

Very crude and almost incorrect defination. Namespaces are basically used to resolve name collisions. You can look here for what it actually is.

This line initializes a function called "main" this is your core function all programs need to have this function.

"Initialize you say" ;)
This stmt will cause many developers to go into spasms.

cout is the command that tells your program to output something

Actually its much more complicated than that...
Better use the word functions than commands.
Using vague words like "something" doesnt cut ice.

and the endl tells the program to end a line you can use "\n" to get the same effect.

endl actually causes the effect of using '\n' along with "flushing the output buffer.
Therefore

endl => putchar( '\n' ) + fflush( stdout )

And many more...

Now to the main point..it would be better if instead of correcting the mistakes, you just start learning the itsy bitsy details of the language and then write tutorials. Instead of asking us what the problems are and then correcting them, why not rise to a level where you would be in no need of counsellling as such.

Think of it this way..by writing wrong things you are actually "misguiding" newbies that come to your site and those …

John A commented: I like this post. --joeprogrammer +3