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

What part of:

Do use clear and relevant titles for new threads -- your title is worthless
Do provide evidence of having done some work yourself if posting questions from schoolwork assignments -- Nothing for us to help with

did you fail to understand?

These are from the Member Rules you were asked to read before posting. Based on this post, you seem to want us to write it for you.

Please try again in another thread.

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

We seem to have a 1:97 chance of guessing what line the error occurs on, which is difficult at best. The cool thing is if you supply enough details, we can certainly help.

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

Hi I want to know : 1 how to add a persons name to the end of a dynamic array?
2 how to check if the array is full, and if so to print a constant string?
3 how to search in a dynamic array for a specific name and replace it?
4 Returning a name at a specif index in the dynamic array

Exactly as you would a regular array. There is no real difference.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
#include <stdio.h>
#include <conio.h>
main()
{     int i;
      char full;
      char array[10]="ABCD";   // Create the array with 4 letters followed by \0
      for (i=0;i<=6;i++)       // Loop 7 times
          full = array[i];     // copy the first 7 characters into FULL one 
                               // at a time
      
      printf("%c",full);       // output the value of array[6]
}

You are outputting the character. So what is the value of array[6] ?

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

Because, obviously, you did it wrong. Don't you think that showing us what you tried to do would give us some helpful information? This is not the Psychic Programmer's Forum.

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

If tiredoy's post didn't help, you might need to give a more detailed explanation of what you need help with.

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

Are you kidding me with this post?
1) Title: C++ Program -- Really? I never would have guessed! In a C++ Programming Forum I figured the post would be about making hamburgers.

2) Post itself -- and what are we supposed to do with this information? Write it? Give a detailed explanation of what you don't understand? Print it out and wash the windows?


Thread closed.

Salem commented: Now that's what I'm talking about! +17
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why can't you do it in the console?

Open the file in binary mode.

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

OK Guys, enough showing off. Let's help Sonia11 and less trying to impress her with your prowess. I'll bet she's not interested in your C++ muscle and just wants to finish her project.

NathanOliver commented: well said +9
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'm not going to use it, I was just taking the "C programming" skills test on oDesk, and it always uses "void main()" or "main()" and it's god-awful garbage code on the test the whole way through.

I still plan to use oDesk though because the testing thing is at least a nice idea.

Sorry, but that sounds stupid. If you want to increase you skills, why use something that doesn't have the skills you need? Would you ask your little brother to check your calculus homework? Would you ask an armless man to teach you to shoot baskets? Would you ask a blind man to teach you to draw?

Garbage code is garbage code. What positive things can you actually learn from it? You're fighting the learning process all the way.

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

if i wont use goto whats the alternative for that? how will i call mathematics in my program. so far when i simulate it without including the mathematics function, it allows the user to enter the first and second number, then my problem is the logic behind that. How? :(

1) Call the function input the 2 numbers. Return.
2) Call the function to add the two numbers. Return.
3) Call function to display the answer. Return.
Put all that in a loop that asks if you want to do it again.

For #1, just ask for the 2 numbers, don't try looping in the function. Or input 1 number and call the function a second time for the second number.

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

Go to your profile and remove/fake all the personal information. Based on the info I see publicly, you live in Wellington. Nothing else. How is that threatening? Especially if you change it to Caloris Basin, Mercury?

In fact as there has been significant change to the service you should have asked us to confirm that we accepted the changes. You have basically just changed your side of our contract without discussion.

When did it change? Only the site formatting has changed that I know of. What was the service description when you signed up, and how is it different now?

Anyway, this bit IS A PERCEIVED THREAT. Stoip stealing people's data/identities or your site will probably disappear from the web for several weeks, just long enough to bankrupt you I would imagine!

Planning something interesting? Thanks for the warning. We now know who to look at first if it happens...

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

I need to know a bit about this "default int" thing in C. What I mean is, is this actually ok and with what version of C is it ok?

I guess my question would be "why?" If you know int main() will always work, why would you need to know when "default int" is OK? In other words, if you know A sometimes works but not always, and B always works, why understand A? Just ignore it.

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

Do you want to do something more than once? If so, yes. If not, no.

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

for example I want create a textfile named as text1.txt and another textfile text2.txt.
What possibly is the solution to prevent the 1st txt file to be overwritten by the 2nd txt file.

Don't write the same thing to both files.

Why would text1.txt get overwritten by text2.txt? they are two different files.

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

Gee, I wonder what you types in. I also wonder what answers you got.

Any help is dependent on the input and output.

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

Just to clarify, Walt, let me restate the rule so there is no confusion on your part:

Do ensure that all posts contain relevant content and substance and are not simply vehicles for external links, including signature links

Posts that are not relevant and/or have no substance and act as vehicles for external links break the rule.

Posts that are not relevant and/or have no substance but do not have external links do not break the rule.

As Nick says, being stupid isn't currently a crime. Those posters who do not break this, or any other rule, but otherwise fall into the annoying dumbass category should be dealt with by way of a guiding hand PM from the mods which serves to gently prod them in the right direction towards becoming a valuable member of the community.

Ahhh, then the rule is backwards. As stated, content is of primary import for all posts and links is secondary. Your description explains that the links are the most important and content must be existent IFF you post with links.

Therefore the rule needs to be restated more like
Do ensure that all posts that contain external links, including signature links, also contain relevant content and substance
to accurately describe the rule.


Sorry for being pedantic here, but if I'm confused by a rule, many others (especially the stupid) will probably not understand the rule. I'm simply trying to make it understandable to all, including us mods, so …

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

after my task done it also returns some junk value like some different symbols how to avoid it?

Don't know. We are unable to see your code as it is now, we don't know what your input was, we don't know what your output was.

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

>> Do ensure that all posts contain relevant content and substance
>> and are not simply vehicles for external links, including signature links

Not necessarily an either/or. What about people who post stuff like you just posted ("thank you diz iz greeeeat post!") but who don't have an ulterior motive like spamming, but rather just an imbecile who, while possibly thinking he is adding something, isn't. Does the inane post lacking substance break a rule in and of itself? Other than the leet-speak?

Do ensure that all posts contain relevant content and substance is the rule.
and are not simply vehicles for external links, including signature links is simply a dangling statement that has no real bearing on the rule. The 'rule' includes many types of posts that are not allowed, whereas the dangling statement includes only one explicit type and therefore confuses the rule. Restating the rule without the confusion:
Do ensure that all posts contain relevant content and substance. For example, posts that are simply vehicles for external links (including signature links) are not allowed.

IMAO.... :icon_wink:

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

You can't. It's a static string and cannot be modified.

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

Try reading the thread.

Salem commented: thanks for finally staking this zombie to the ground! +17
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I understand what you meant by changing it to static but how do I add the previous sum to the "new" sum in the for loop?

Because of static, the old sum is already in sum, or whatever. Static values have the previous value in them each time the function is called.

Here's my code. When compiling the code it asks to input a number, you must insert 4 everytime. Then the output should be 4; 2,666666667; etc.

So why is it asking? Is there a reason to have the function ask for a number?

And when compiling, the code asks for nothing. When running it asks for the number.

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

Create your 1x6 array initialized to 0's
Loop through the 2nd column and take the integer (nor rounded) value of the value as an index into the 1x6 array, and add the first column's value.

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

In approachPI(), make the sum static . That will remember the last value from the previous call. You can static any other values you need to remember. Be sure to set them to their initial values.

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

Sorry, we are not a homework service. You'll have to write it yourself.

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

Int to string is easy in C++ with a "stringstream", or if you prefer you can use an old C function.

int someInt = 256;
string out;
stringstream(someInt) >> out;

And how does stringstream solve
1) recursion
2) comma-separated blocks?
It helps to read carefully... :icon_rolleyes:

Hey Kid, read the forum rules and add the information you forgot.

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

Okay sorry I fixed it now. Now how come I can't get the program to run?

I fixed #1. #2 and #3 are still unknowns.

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

Major Fail!

1) No CODE Tags so the code is unreadable
2) No explanation of what the code is supposed to do
3) No explanation of what you're having trouble with

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

Since when is main() a char function? Of all the errors I've seen for main() , this is the first time for this one...

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

The best language is the language that has:
1) File Input
2) Console Input
3) Console Output
4) IF statements

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

Print the data and see. Your best test to see if something worked is to look at the values by displaying them, or using the debugger.

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

I'll tell u a bit of detail about ADRESL...

Doesn't answer one of my questions. I suspect you will find you think you are using positive values but they are signed and negative.

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

What's the value of ADRESL before the IF statement? Is it a byte or an int? signed or unsigned? 0xF5 is a negative value if a byte.

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

I don't see any attempt at more than one else-if . That's probably why more of them didn't work.

Learn to format your code properly. It's hard to read as it is.

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

What problem? We didn't write the code so we don't know if it's right or wrong either. It might help to tell us what you're having problems with. We aren't psychic -- we're programmers.

Salem commented: But I knew you would say those things... +17
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i tried getline (myfile,line,":");
but didnt work.

My guess is you did it wrong. But since we can't see your screen, it's hard to suggest a fix.

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

does that work....i'm having problems in the simulation...the first else if doesnt work in the correct range that Yellaiah told me....

Then you did it wrong. Without seeing the code, we can't offer suggestions.

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

Look again at getline() and consider its 3rd parameter.

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

I'm listening to my arteries harden...

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

the problem is in this portion of the code

scanf("%c",&choice1);

try puting a space betewee " and %C when declaring the variable type char, this sometimes refuses to accept the input and porceeds to the end or enters a random input instead

try replacing that piece of code with this one and see what hapens

scanf(" %c",&choice1);

And how would that help? Why would the correct way (before your change) 'refuse' to accept input?

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

I realize it's a quite a lot of questions, but it's been a few days and I keep banging my head against the wall..

Actually, there were no questions at all. Just a general description of your project.

It helps to give us the details about what you're banging your head about so we know what you need help with. I hope it's not "discard the first 5 lines" since that's the easiest part of the task.

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

I don't understand your logic here:

printf("Do you want to enter another contact?Y/N\n");/*condition question of loop*/
	scanf("%c",&choice2);
	if (choice2 == 'y' || 'Y'){
		choice2 == 'y';
	}else{
		break;
	}
	}while(choice2 ==  'Y' || choice2 == 'y');

Accept [I]choice2[/I] If [I]choice2[/I] is eith 'y' or 'Y', change it to 'y' -- this is nonsensical - it's already 'y' or 'Y' otherwise exit the DO-WHILE loop At end of DO-WHILE, test for 'y' or 'Y' -- you just set it to 'y', so you know it must be true. It can't be anything else because if it was you already broke out of the loop. And why test for 'Y'? You set it to 'y' so it can't possibly be 'Y'.

In other words remove the IF statement completely. It's redundant, unnecessary, and extraneous.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
ch=fgetc(cfptr);
while (ch!= EOF){
      printf ("%c", ch);
//-----------------^ put it right here
      ch=fgetc(cfptr);
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i wrote a program to take text from a file of my choice named "data" and print it out on the screen, how can i tweak this so taht when the text comes out , it would be all in upper case using toupper??

1) what does toupper() do?
2) how do you call it?
3) what does it return?
4) where is the most logical place to put the call to accomplish your task?

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

Define alignment. I for one have no idea what you're talking about.

Salem commented: Ditto +17
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

thanks, i will work with all your sollutions and see what will bring the desired result in this case
its all about the result not how you got it in programing isnt it ???

thanks anyway

Not necessarily. You can get to New York to Philadelphia by way of Cleveland, but just because you got there, is that an acceptable route?

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

Need help on this not for sure what I am missing I get a couple of errors!In included both the .h and .cpp information.

A couple of errors? Must be something wrong then. But since we aren't psychic, you might want to be less vague.

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

The usual way of computing min and max goes like this, in pseudocode:

cur_min = a-number-at-least-as-big-as-the-data-minimum // INT_MAX works
cur_max = a-number-at-least-as-small-as-the-data-maximum // INT_MIN works

I would start out slightly differently:

cur_min = first-number-in-the-array 
cur_max = first-number-in-the-array

This way you don't have to guess at a hopefully large/small enough number. And the first number in the array could be the largest or smallest. And it's part of the list anyway.

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

You would. It's lame, rigid, and two years old. There are much better ways, and many have been posted in the past two years.

mattdeximo commented: you are a big help in my activity thankyou +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sorry, but regardless of the errors in your code you have the wrong algorithm.

As do you.

You seem to have assumed that you can translate directly from base 10 decimal numbers, you cant. Eg. Consider 49. That would be written IL. however, your code
would produce XL1X.

Whereas the 'more correct' correct answer is XLIX.
I can negatively modify V & X
X can negatively modify L & C

Using your algorithm, 999 would be IM, which is not normal.

caveat: there are arguments for both techniques since there is no real standardization. But a fairly common interpretation is as above in lieu of a documented standard.