Strange error in my C program. 'Bounded buffer problem'

emiii0

Limp Gawd
Joined
Aug 31, 2004
Messages
297
Ok. So my program is finished, or so I think.

The output on my computer is something like this:

Producer 1: aaaaaaaaaaaaaaaaaaaa
Producer 2: 00000000000000000000
Consumer : aaaaaaaaaaaaaaaaaaaa
Consumer : 00000000000000000000

Which seems fine, however when I run this code on the computers in my school lab it does this:

Producer 1: aaaaaaaaaaaaaaaaaaaa
Producer 2: 00000000000000000000(0123456789) *Items in parenthesis should not be there.*
Consumer : aaaaaaaaaaaaaaaaaaaa
Consumer : 00000000000000000000

Why is it adding that array to my producer 2? Here is the code from my producer 1, producer 2 and consumer routines:


****CODE WAS REMOVED BECAUSE PEOPLE IN MY CLASS STOLE IT******
 
You're using %s to print a string that isn't null-terminated, so printf() starts at the address you pass and just keeps on printing. On your home machine, you're lucky and find a null before you run into something else. At school, you unluckily run into something printable first.
 
That was a popularity contest, not a programming contest. Happy to help, tho!
 
I know that mikeblas already found your answer, but please use the code tags in the future. It makes things much easier to read.
 
lol it is Big Al jerk... i laughed today when you were asking the same questions in class
 
You can also use printf to print strings (or part of them) that are not null terminated if you know the length that you want to print. For instance, if I had a character string "str" that I wanted to print the first 4 characters of, I could have the following code: printf("%4.4s").
 
I've always been responsible for some level of hiring wherever I've worked. At my current job, I screen and loop most of the engineers. Hiring is very difficult; I'll read about 100 resumes to find 3 people to phone screen. Of those three screens, only two will go on to an interview loop. We'll interview about four dozen people before making an offer to any one of them.

It's incredibly frustrating. Where are all the experienced, talented, insightful software engineers?

Maybe it's time to close this thread before even more NO HIREs come out of the woodwork.

rafa1385 said:
mikeblas said:
rafa1385 said:
Hey dude can you please sent to me the code for the bounded buffer problem.. Is because is my final project, and I have a bad teacher that he doesnt teach anything.. so I dont understand how to do it and is due for wednesday of this next week.. please help me........ thanks dude !!!!
No.

Why not bro? please.. or can you help me to do it or something.. think about bro..
 
I've always been responsible for some level of hiring wherever I've worked. At my current job, I screen and loop most of the engineers. Hiring is very difficult; I'll read about 100 resumes to find 3 people to phone screen. Of those three screens, only two will go on to an interview loop. We'll interview about four dozen people before making an offer to any one of them.

It's incredibly frustrating. Where are all the experienced, talented, insightful software engineers?

Maybe it's time to close this thread before even more NO HIREs come out of the woodwork.

all I could think of was "Don't tase me bro!"

I'd like to think I'd be a talented insightful software engineer. Unfortunately, none of my professional experience is in that field of IT. (all networking / system administration and now management)

So when a hiring manager see's my application for an entry-level developer position, they think i'm crazy or something. (even though the entry-level is well within my capabilities, and pays similar or slightly lower)

Shifting career paths is hard work. :(
 
It'll be "don't flunk me, bro!" before the end of the semester, I'm sure.
 
I've always been responsible for some level of hiring wherever I've worked. At my current job, I screen and loop most of the engineers. Hiring is very difficult; I'll read about 100 resumes to find 3 people to phone screen. Of those three screens, only two will go on to an interview loop. We'll interview about four dozen people before making an offer to any one of them.

It's incredibly frustrating. Where are all the experienced, talented, insightful software engineers?

Maybe it's time to close this thread before even more NO HIREs come out of the woodwork.

Or we should lock it before your ego grows any bigger...

*Just a side note. I'm surprised how many people Google code for their homework. I learned about 3 people in my class finding that code and I received 2 private messages from people on here for the rest of it.
 
Ego? Because I'll only consider candidates who actually know what they're doing? Is that what you're going to tell the interviewer if you can't use Google during your interview?
 
Awesome. Two NO HIRE's in one thread.

If you were following along with what you typed out then you would notice that you posted the above reply to insult Biggal0043 and myself after our conversation, and I never said anything about Googling my code, because I didn't. So, that would be why I said something about your ego. And on that note, I'm done. A lock is definitely needed.
 
Back
Top