Thread: persisting problem with a function call

  1. #1
    Registered User bluetxxth's Avatar
    Join Date
    Feb 2010
    Location
    sweden
    Posts
    43

    persisting problem with a function call

    hi all,

    I seem to be running into the same problem over and over again.

    To make a long story short, I am trying to make a part of the program display usd into euros and vice-verse. I am having trouble again with that part which has to do with the function call.

    On the main function I use a scanf to take input from the user and pass that to the formal parameter 'currency' currency then is used to compute the exchange amount with a rate rate1 for euros and rate2 for usd. Then I assign the product of rate1, rate2 and currency to a variables change1 and change2. when I want to display the exchange in euros I use one and when I want to display the exchange in dollars I use the other.

    However, instead of getting the exchange in the desired currency I get the input I introduced but not the conversion. I paste the code below. Thnx / bluetxxth


    Code:
    /* 
     * File:   main.c
     * Author: buetxxth
     *
     * Created on October 6, 2010, 1:31 PM
     */
    
    #include <stdio.h>
    #include <stdlib.h>
    #define  RATE 1.3 // the exchange rate
    
    void change_chooser(double currency, double change1, double change2) {
    
    
        double rate1 = 1 / RATE, // euro conversion rate
                rate2 = RATE; // usd conversion rate this is  1.3
    
    
        change1 = currency * rate1; // for usd to euros
        change2 = currency * rate2; // for euros to usd //
    
    }
    
    int main(void) {
    
        int option;
        double chge1,
                chge2,
                curr; // to be copied to the forma parameter
    
        printf("Choose option: (1-2) ");
        scanf("%d", &option);
    
        if (option == 1) {
            printf("\n Desired Exchange in EUR\n\n"); // prints the choice selected
            scanf("%lf", &curr); //this gets copied in te formal parameter currency
            change_chooser(curr, chge1, chge2);
            printf("%f EUR cost %f USD \n", curr, chge2); // prints output of choice selected in usd
    
        } else if (option == 2) {
    
            printf("\n Desired Exchange in USD\n\n"); // prints the choice selected
            scanf("%lf", &curr); //this gets copied in te formal parameter currency
            change_chooser(curr, chge1, chge2);
            printf("%f USD cost %f EUR  \n\n", curr, chge1); // prints output of choice selected in usd
    
        }
    
        return (0);
    }

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You need to pass by address or pointer. It is important that you learn this concept.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User bluetxxth's Avatar
    Join Date
    Feb 2010
    Location
    sweden
    Posts
    43
    Hi Elysia,

    Thank you very much for your answer I was suspecting that.

    BR,

    bluetxxth

  4. #4
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314

  5. #5
    Registered User bluetxxth's Avatar
    Join Date
    Feb 2010
    Location
    sweden
    Posts
    43
    Are you the admin of this site?

    I am contacting the admin of the other site to ask a couple of questions.....

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    What need is there that you have to contact the admin out of all people?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Why did you ask the same question in your other thread -- which I answered -- then open up yet another thread?

  8. #8
    Registered User bluetxxth's Avatar
    Join Date
    Feb 2010
    Location
    sweden
    Posts
    43
    First of all,

    Thank you for all the answers I received. I really appreciate them, they have always been useful and very quick. I have been using this forum for a year now and I can't do anything but thank you for all the help I have gotten so far.

    I asked in to what I perceive to be a totally different forum because :

    1) Your answer did not totally dissipate my doubt. The warning is not all what was going on there there was a problem with a misplaced statement. When I solved the problem that had to do with your post I had a new issue of a similar nature and I did write an answer there but I later edited my post and deleted that because I perceived it to be a new issue that had to do with pointers. On the other side I did not want to hammer you with the same question. Notice that later on I did receive other answers that did dissipate my doubts completely, I did need pointers.

    2) As for the other forum I needed a fairly immediate answer. I have a project due and I did not understand how some of the things which I need work, despite having spent many hours in front of the computer trying to solve the problem through understanding rather than copying. At the very least now I understand why because I found out by means of testing.

    3) I did not know that it was against any rule in this forum. I sincerely apologize if it is forbidden to post in different forums the same subject.

    If there is any rule that forbids to post on other forums the same question I, again, apologize my ignorance.

    However, if I made a mistake, in my subjective opinion, there are certain ways to courteously point out what is generally accepted or not in this forum, and other as well.

    On that other forum there was an individual that answered me "JUST ANOTHER CROSSPOSTER" and threw a link to this forum where I had posted the same question. I did not simply not like the answer. I did not understand it.

    Not much for the answer which does nothing really but because of the attitude. The dude went and bothered to post that comet, threw a link and put me in this situation rather than helping and / or pointing out that in his opinion CROSS POSTING was not acceptable. Notice I have just learned this term CROSS POSTER just now despite the fact that I have been using forums for advertising products (computer hardware) for over 10 years now. Rest assured I will go and read the whole section on rules on this forum and on the other.

    Most importantly, I perceived this comment directed to put me down, posting to inconvenience, ridicule and put individuals who have an honest question on embarrassing situations, and to try to taint their name so that they don't get any help should not be allowed neither here nor there.

    I don't even know why I paid attention. It clearly bothered me because I have always taken good care to be courteous to people here and everywhere else. Secondly I have always had courteous people helping me here and in other forums and that is what I grew used to. This attitude did a bit more than just bothering me.


    I hope that answers your question.

    Best regards,

    Bluetxxth
    Last edited by bluetxxth; 10-07-2010 at 01:18 PM. Reason: forgot one detail

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    People usually tend to get rude when they see a familiar and hated action. Cross posting is frowned upon because when you are helping people, you put down your time to help them. If someone else just helped that same someone you tried to help, it doesn't feel fun anymore.
    You just wasted your time helping someone who got help elsewhere. That is why cross-posters are not liked.

    Unfortunately, in this, and many other places, people just throw you in with another bunch of people, and label them "cross posters", which usually means some bad group of people to ignore, hate or complain on.
    Don't take the criticism personally. Instead state your reasons clearly and calmly and often people might just forgive you for doing so.

    Cross posting isn't against the rules. It's just net etiquette. Unwritten rules that exist in society.
    Also, it is not good for you if you do your project in the last minute. Then you'll get into the situation of cross posting and whatnot, which is frowned upon.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User bluetxxth's Avatar
    Join Date
    Feb 2010
    Location
    sweden
    Posts
    43
    Thank you very much Eylisa for enlightening me really!!

    Just put yourself in my shoes...

    I am currently studying computer science and I have recently subscribed to a forum in order to post a question regarding function calls. I think my inquire is legitimate and that I don't break any rules by posting in your forum as far as I can read on the forums FAQ general rules section.

    There is, however an answer from an individual, to my inquire which in my opinion aims to discredit, embarrass me, and to deprive me from help here in your forums and in other as well, and to put me down Just because I had posted the same question in another forum. Ignoring completely that it is in bad taste and bad etiquette as you say to CROSS POST.

    This individual called me CROS POSTER in capital letters and then he went and he threw a link to my question in the other forum.

    The post in question can be found following this link: Problem with function call - Dev Shed

    Consequence>

    This attitude has caused other people in this the forum, where I normally post and enjoy reading and contact people with my common interest to respond angrily at me and be disappointed, which is again what I perceive that post was aimed at.

    I am certain that this was not neither what this forum was intended for nor the other one. Furthermore, take notice that instead of helping, the individual in question has chosen to willingly to act in this way. In my subjective opinion that individual has wasted more time and characters in answering me in this destructive fashion than just by telling me that I needed to use pointers and perhaps even by pointing out in a courteous manner that cross posting is not generally acceptable in this community something I totally and honestly ignored. Notice I do tend to read the general rules before I post.

    You see... looking from that angle perhaps you will understand how angry and disappointed I felt, that instead of focusing on my work which is due tomorrow I spent my evening drafting these messages I send. Why? because I do really care about the answers I get and out of hope that this will not happen to other forum users and to gain back respect from those who did help me on this forum to whom I am deeply grateful.


    Having said that receive my most sincere apologies, and rest assured that not only I do appreciate, and value like gold the help I receive here, furthermore, I invite anyone who usually post in any other forum to browse here for the tutorials and the help on the forums. And be sure about it, once I have understood that CROSS POSTING is not generally accepted it will never ever happen again.

    Best regards,

    Bluetxxth
    Last edited by bluetxxth; 10-07-2010 at 02:18 PM. Reason: ortographic correction

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I understand your position. Usually I do not accuse people, or try not to, without having attained discrete proof of something.
    That said, you are most welcome here in my opinion. Obviously you did not know cross posting is considered bad, and made a mistake. Yet you apologized for it. So now everything is OK.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Registered User bluetxxth's Avatar
    Join Date
    Feb 2010
    Location
    sweden
    Posts
    43
    Thank you very much Eylisa I am really very sorry!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Help calling function is asm
    By brietje698 in forum C++ Programming
    Replies: 24
    Last Post: 12-06-2007, 04:48 PM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  4. how to get function call stack
    By George2 in forum C Programming
    Replies: 18
    Last Post: 11-11-2006, 07:51 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM