WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You already have a thread started. You don't need to start many threads on the same topic.

And you neglected to read any of the requested information posted all over this site about CODE tags, like
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) Even on the background of the box you actually typed your message in!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You need to use a loop and divide the number n by each odd number from 3 to n/2. If any number divides n evenly (no remainder) n is not prime.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Let's see...
No CODE tags, even thought there are at least 6 places they are explained, and 3 of them on the main page alone.
No explanation about why code was posted
I guess all there is to say is:
Congrats for writing some code! What's next?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Let's see...
No CODE tags, even thought there are at least 6 places they are explained, and 3 of them on the main page alone.
No explanation about why code was posted
I guess all there is to say is:
Congrats for writing some code! What's next?

yellowSnow commented: Persistance against a never ending wad of crap posts. +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

hello! I just made a palindrome. that inputs an integer between 1 and 9, and should output:

We're glad you wrote the program and it works. Very proud of you.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you want to know how a program works, plzzzzzzzzzzzz post a program. Or try reading the Rules for the site.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you can't give us any more information than just posting almost 200 lines of uncommented code with no indication what's wrong, where it's wrong, and not using CODE tags, then there's no real help we can give.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Look into the modulus (%) operator.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First of all, format your code so it can be followed.
This code:

m = ~(arrX[I]);//convert to unsigned
m == m+1;

does not convert to unsigned. m == m+1; is a comparison. Since you know arrX[i] is negative, just do arrX[i] = -arrX[i];

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Since doubles are rarely exact, probably your loop counter is wrong. For example when you think i=4 it's probably i=3.9999902 or something like that.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First, format your code.
Second, explain what you need help with. Don't make us guess.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

can somebody figure out whats happening.

#1) No code tags
#2) void main() is wrong -- see this
#3) No formatting makes the code difficult to follow -- see this
#4) feof() misuse -- see this
#5) Reading and writing to the same file makes the program difficult to follow, and likely to generate bugs

I'd try to find code that isn't this screwed up.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I do. And nothing is EVER urgent here. Read the Rules, please.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The rename() function renames, does not copy. You need to open 2 files: the original file for reading, the new file for writing. Then read the old file and write to the new file.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

From another thread...

Are you aware the little rep counters are actually little buttons to easily up-vote or down-vote a post without affecting someone's reputation points? ... But meanwhile if you do give reputation it also up-votes or down-votes for you automatically.

Oh, so that's what's going on... Got it!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Are you aware the little rep counters are actually little buttons to easily up-vote or down-vote a post without affecting someone's reputation points? ... But meanwhile if you do give reputation it also up-votes or down-votes for you automatically.

Oh, so that's what's going on... Got it!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK, so if I want to simply give one single rep point, click the up button, as I did to jbennett above.

Or add your entire rep allotment by clicking the add link, as I did for kaninelupus. But the number is not modified.

And I agree the buttons are very cluttery as well as the bold number.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
for(i=loc;i>=first;i--)
{
	if(sorted_array[i] != key)
		first=loc-1;
}

A while loop would be better here...

if(key=sorted_array[first])
{
	count2++;
	first++;
}

... and here.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes, be consistent with your input. Always use getline() and you shouldn't have to worry about cin.ignore()

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You need to format your code before posting...

No idea what you are asking. Distinct prime factors? Of what? Show us an example...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

But it does say that people that have clout like what you say... :icon_wink:

jasimp commented: True +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

... DaniWeb is skewed towards a more tech saavy audience.

Why would tech savvy be equated with higher than 1024x768? Don't tech savvy users use laptops? Aren't there a few tech savvy users older and need glasses?

I'm with AD on this one. I personally use windowing, which to me means multiple windows opened at any one time, and I very rarely (maybe 0.5%) ever have any window open full screen. My standard window size for web browsing is about 2/3 of my screen setting, making the main nav bar end at the word BUSINESS. I'm always scrolling to see the 'community guy'. And I consider myself fairly tech savvy.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK ...

Thread preview now works for code snippets, so you can see exactly what the formatting will look like before you post. Everyone who submits a code snippet should always preview it first!

Maybe only the PREVIEW button should be available during initial composition. Then SUBMIT can be available only from a PREVIEWed screen. Just a thought.

Dani commented: I was actually thinking that myself. +0
majestic0110 commented: Jolly good idea if you ask me! +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Interesting. This caught my eye:

Governments and legislators chip in that the combined lack of enthusiasm from both sides of the TV industry suggesting it is pointless in legislating to force them into making the technology available when people clearly do not want it.

Isn't that what they said about talking pictures? The public even thought it was just a gimmick and would go nowhere....

Anyway, does this mean that the Audio Description must be close captioned? Just a thought... :-p

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

To get a binary value from a decimal value v = val %2; -- v will contain the value of the ones digit. Then, after you get the digit, remove it to get the next digit: v = val /2; Loop until val is 0.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@Salem
Why would you use spaces instead of tabs? I never understood that, I always set it to tabs - then one keystroke/character replaces several, no?

Yes, but if set to spaces, pressing the TAB key can add 4 spaces which makes code much easier to read. And when posted here, where tabs are always screwy, helps us read your code.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Are you talking by experience?

Pwobabwy

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

help please ok here is my code

void sleep()
{
      energy 100;
      happy + 20;
      strength - 1;
      bladder 70;
      age + (hour * 8);
};

ok? all the varibles are preprocesser defined, you know #define energy 100.

If this is true, what does the statement 100 100; do? (first statement)
What does happy + 20; do?

All I see are compiler errors.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Learn to Format your code. That generally solves every bracket problem immediately.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

weird is not an approved IT term. Be specific. Give details. What is the first question your mechanic would ask if you told him "my car is acting weird?"

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Excellent! Have fun ~s.o.s~!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Since it's a text box, just look at every character in the box and remember the index of each 2 you come across.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

C'mon guys, the answer is simple.

why C is a not a object oriented program ?

Because it was designed as a procedural language. Simple as that.

Salem commented: One single moment of clarity, then C++ was invented ;) +36
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am too new to c programming.I think as the program doesnt return any value you should either put void main,

NEVER use void main()

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1) Accept input from the user
2) Open the file
3) Read a line
4) Use strcmp() to see if the measurement is at the beginning of the line
5a) If not, back to 3
5b) If so, close the file and continue.

Also, check out these links:
Formatting C / C++ code
fflush(stdin)
scanf() series

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What statement causes the error? Do you really expect us to search through 200 lines of code we didn't write to find an error that is unknown?

Please give us enough details to help you.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Nothing wrong. A char type can hold values from -128 to 127 only, a total of 256 values. So, 321 is too large and the extra basically falls out the end.
321 - 256 = 65
128 - 256 = -128

An unsigned char can hold values from 0 to 255. Still 256 values.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You have a ; you don't want at the end of the while statement:

while ((c = getchar())!=EOF);
      if(islower(c)){
      	++letter[c-'a'];}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

gurdeep kaur, how does your post help Lenny19 with his problem? Or do you have a new question which needs to be asked in it's own thread?

Before starting your thread, read some of the posts that explain how to post your question properly, which includes The Rules.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Has the book been released in ebook form? Did you search for it?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

can anyone help please

Sure. I added the CODE TAGS you ignored, which are described
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used
6) Even on the background of the box you actually typed your message in!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hello all,

in time of need I always come here to cry for help)

Anyways. What I need to do is to store data about people in a binary tree. They need to come from a file, but for now I can hardcode them in.

Well, I suppose the first thing you could code is the input function and get that out of the way...

To put it simple, I will have 10 people (probably defined as structures with name, surname, age, phone number variables) where surname acts as a key.

I am totally new to binary trees - does it mean I will need to have a tree of structures? I have some sample code, but it only works for numbers, how can I modify it so it will take structures?

Yes. How to modify your code? Replace the integer data field with your structure data. The integer information is already defined in a structure, is it not? Just replace it with all the fields you need to keep track of.

How do I go about it? General tips and even code would be great!

Use your editor... Since you posted nothing, I can only guess -- or use my psychic powers. Which would you like me to do? :icon_wink:

Also, I found some sample code and it has weird "->" symbols - what do they mean in my context?

A structure element is referenced using a dot, as in person.age , get the age field …

Lioshenka commented: Thanks +3
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If usually starts with headers, then int main() . Then there's an input of some kind.
Then you get some if statements with some math intermixed, maybe even a loop or three, and finally some output statements.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Code tags explained:
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) Even on the background of the box you actually typed your message in!

Somewhere in those places you should become a CODE TAG expert.

"The array element that corresponds with
that character's ASCII value is incremented by one ...

You have an array of 128 items (call it charList ), each one corresponds to one character in the ASCII chart. The array element (a character from the input array) is used as an index into charList and that entry is incremented. That character is now counted.

... along with a counter called textLength that tracks the number of entered characters.

textLength is incremented for each and every character and counts the total number of characters entered.

The frequency table [charList] , headers [?] , textLength, and the percentage of all the characters printed.

I think you missed something here.

Then a "for" loop incremented by the 128 elements in the standard ASCII table uses a condition to check if the value of the …

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My blade never gets dull, but I sure do get tired of the blood stains: :icon_rolleyes:

David Brin would be proud.

(see his book The Practice Effect)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@guru_boy:

It's generally considered rude to resurrect ancient threads, for any reason.

You didn't bother reading the thread before posting eh?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

... but doing something for the sake of the standard where it saves me a bit of effort to do it in another way that works just as well is retarded.

Makes sense. Let's use this attitude elsewhere in life. Gee, stopping for that red light ahead is just an arbitrary rule some committee came up with. Going through the light in and of itself won't be a problem, the light can't hurt, and I won't have to step on the brake. Stepping on the brake for the sake of a light is retarded.

And yes jephthah, Microsoft did it. Look at how many non-standard things Microsoft does and gets away with.

And look how many fixes they have to make every month because they cut corners and don't follow standards. Can you name another major OS that crashes as often as Windows? Maybe int main() does make a difference you're unaware of....

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

:icon_idea: Maybe we can all learn from the Ancient one... :icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I called shenanigans and they delivered some Cock-A-Leeky soup and some nice roast mutton.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So with the sudden disappearance of Narue, the moderators are free to do anything the want right? I mean: no control what-so-ever until there's another s-mod?

Just try it, I dare you! :icon_twisted: