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

bats -> ultrasonic waves

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

so that you

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

About how he is trying really hard to get away from sanity...:P

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

Here in my room - Incubus

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

Bearing in mind that if this is a console application, there's a finite number of characters for any given line which you can output without the code spilling over to the next line, and completely ruining your formatting anyway.
Therefore, it may be simplest to put in an upper limit to the number of lines the program can produce, given the constraints of your environment.

...or better yet to redirect your output to a text file which can hold virtually infinite data, thereby removing the need for an upper limit.

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

I remember having arguments with you or WolfPack because Shamans don't ressurrect the dead :)
Those were the days indeed.. What happened to WolfPack anyway? I haven't seen him for a while?

Niek

Maybe he was bitten by a She Wolf....;)

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

That was a bad example. dir C:/WinNT might be a better one :)

Well, it you are so well aware you are using a MS windows OS along with the fact that there is no command named dir in *nix, it is better if you use dir c:\winnt . ;)

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

I have been struggling with this program assignment for weeks now. Can someone offer some advice on how to only accept numerical input, and to reject anything else? Here is my code.

For the purpose you are trying to achieve, I wouldn't recommend scanf. It offers so very little control over what the user enters and also validation becomes a pain. Better accept the entire input as string and write your own validation functions. More info here.

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

Isn't C portable to the point you can creat an OS with it???

I think you have your concepts blurred there. Portability roughly impiles the same standard C code can be compiled on Windows system as well as Unix system. (of course provided you don't use external libraries).

Yes, C can be used to create an OS with it (and it has already been achieved), but for interfacing external devices like the hard drive or floppy drive, you need to write a program (ie a driver) which will act as an interpreter between the OS and the device.

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

But I heard somewhere that you can still use forward slashes in C++ programs under Windows; correct?

Yep, actually using forward slashes is the most portable way of putting slashes inside commands such as system as well as while hardcoding file path, rather than using \\ which works only on MS systems.

my command prompt in Win2K doesn't like forward-slashes when used with commands (such as ' dir c:/ ' - the command complains that i'm using an invalid switch ). Although its ok when specifying the path of an executable - eg ' c:/winnt/explorer.exe '

Thats because the forward slash is actually not required for the purpose you are trying to achieve. You can do system( "dir c:" ) and get the same results.

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

Love (Boyzone)

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

Sorcerer -> powerful spells

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

of a calamity.

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

A few points to be noted Aia :

  • * spacing()
    * parameters:
    * int height --> accept the numbers of rows
    * returns: 0

    I hope you do realize that something returning 0 is not equivalent to something returning void. 0 is after all a number, which in the end amounts to something whereas void is just void and has a special meaning, it just doesn't exist. Hence you should write returns : void and not the incorrect one returns: 0 .

  • The behaviour of the function fflush is undefined on the input stream i.e. stdin . Read this. And for accepting user input in a relatively safe way, see here.

Hope that helped, bye.

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

Tough on the outside, soft on the inside, that's what men are.

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

You get accused for cutting trees.

I put in some twigs.

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

As far as your above problem statement is considered, the solution is pretty obvious and less complicated than you are making it to be. Two solutions leap out to the eye:

1. Create an array of altogether 300 characters, name it product_details and then keep inserting data into it with a delimiter between them, something like a pipe |( use strcat( ) to concat the three items ). [ not so cool, nonetheless a solution ]

2. Create a structure called Products with three char pointers in it and allocate memory dynamically to them based on the input given by the user.

typedef struct 
{
    char* name ;
    char* desc ;
    char* price ;
} Product ;

// accept user input

// pass the user input to a function which creates instances of
// product structure.

Product p ;
p->name = (char*)malloc( strlen( entered_name ) + 1 ) ;
strcpy( p->name, entered_name ) ;

p->desc = (char*) malloc( strlen( entered_desc ) + 1 ) ;
strcpy( p->desc, entered_desc ) ;

p->price = (char*) malloc( strlen( entered_price ) + 1 ) ;
p->price = strcpy( p->price, entered_price ) ;

// likewise create more enteries of the Product structure or if
// required create an array of structure.

Better use one of the above mentioned solutions rather than doing it the hard way.

If you still have doubts, repost.

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

I being a modest person hand it back to you.

I put in a telephone.

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

with Daniweb members.

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

Magic -> Mage

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

Almost.The free space when one part gets full,is associated to the full one,thus increasing in size .In other words the data inserted into the free space when one part is full , becomes part of the full chunk of memory,and NOT to the one that holds the free space

I'll try to do what you've explained s.o.s but
riight now,I don't know how to increase a part ,by taking free spaces from the others.

I still don't get your problem, isn't this what normally happens when we access normal arrays ?

That is, once we exceed the v[29] mark, data starts getting inserted into the second chunk i.e. from v[30] onwards and the same thing happens when v[59] is reached.

I guess you need to explain in a more concise manner.....

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

I don't know if I quite get you but what I understand till now is: You have a memory space which is divided in three parts and if one of the part gets filled, the data is to be inserted in the part which has free space ? Correct ?

To do this, you can initialise the whole array or data space to a value which will distinguish between a free space and an occupied space. For eg. the default value can be -1. int v[90] = { -1 } In the start, your start1 and end1 pointers will point to the same record i.e. v[0] . Then as you keep on inserting data, keep on moving or incrementing the last1 pointer to keep track of the growing chunk.

1. At start start1 = last1 .
2.
If you want to store value check whether last1 has not exceeded its limit then do, v[last1] = data 3. Increment last1 .
4. If last1 has exceeded the limit, make it point to the 30th element and move on to the next chunk of memory.

It would be better if you kept a marker like current_ptr which will keep track of which chunk you are accessing right now.

Hope it made sense.

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

Hmm...I am using the lastest version of Firefox. Maybe you should just provide a direct link to your image via an URL so that it would be easier to access.

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

Fest means only one thing to me, gobble up as much food as you can.

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

Is a image really there ? I don't see any image in my browser window. It would be really a good idea to either attach the image to your post or to upload it at an image hosting site (www.imageshack.us).

Maybe then everyone would be able to help you out.

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

you go again.

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

the risk of

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

You get our HappyGeek.

I put in a candy bar.

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

just for sake

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

"Passion of the Christ" was a good movie.

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

Mine looks interesting, cool, informative...and was very much expected.

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

Powerful -> Majestic

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

so that we

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

make the maximum

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

Alive I feel for the very first time, and I wish I could fly.

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

You get a explorer who really loves the internet.

I put in a bug.

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

space -> Hubble Telescope

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

I draw a picture on it.

I put in some rice.

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

Anyone with enough time to make regular, relevant, and interesting posts....

I guess that's what counts, doesn't it ? ;)

Now s.o.sy, don't start envying other people!

s.o.sy ? lol, Is this a way to get back at me? :D

Not everyone gets to be a moderator, you know! (And that's what I call truly elite...)

*sigh* The grass is always greener on the other side, what else can I say....:D

I have a question: Are these badges permanent, or do they eventually get taken away for someone else to get "featured"?

:mrgreen:

Btw, Mr. Joe, I hope you are trying hard working towards your goal of beating the 40 second mark....:p

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

You get to hear a solo played by me.

I put in a shiny marble.

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

is beyond our

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

impossible -> nothing

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

Hey there Carl, welcome to Daniweb. :D

I am sure there are many newbies out there who need your expertise...;)

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

No, you need not tell anything else.

Miss Dani has come to know that you and I are the only ones causing an uproar everytime with something innovative. (You with shortcut for inlinecode and me for PM for comments on your submitted code) :D

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

Will you (P.O.D)

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

Lessons learnt should never be forgotten.

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

You get to hear "By the Way"

I put in a couple of drumsticks.

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

I always assumed that DaniWeb had the same no-bumping policy as other forums, but I guess I was wrong.

Ah...it really was fun when the policy was strict against bumping threads. Me and Wolfie really had fun closing the threads with a really cool comment ( "Dont ressurrect dead threads like a Shaman" ;) ).

Oh those days.........

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

Now what the

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

Eternity -> Time Travel