Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Online Education (https://www.askmehelpdesk.com/forumdisplay.php?f=401)
-   -   My question is related to c programming. (https://www.askmehelpdesk.com/showthread.php?t=625675)

  • Jan 7, 2012, 08:50 AM
    shivanikoul
    My question is related to c programming.
    Please sort out my difficulty regarding c programming.
    What is the technical meaning of getch() in c programming.
  • Jan 7, 2012, 09:02 AM
    Kahani Punjab
    Shivani Koul,

    Welcome to this great site, first! I hope you are from India. Which state? Girls in India used to keep long/untrimmed hair. Is not it? What about yours?

    getch() returns the character you typed without displaying it on the screen. This is a nonstandard function that gets a character from keyboard, does not echo to screen.
  • Nov 4, 2012, 08:55 AM
    Wajid008
    Take two input numbers save them in variables, also ask user what operation to perform like 1 for addition, 2 for subtract, 3 for multiply and 4 for divide. At the end of each result ask for re-computation or exit?
  • Oct 10, 2013, 07:06 PM
    strongard63
    some type function in c/c++ (at least the one I know) are for ,example , VOID OR INT
    but by I found ,in a website, a code in which there is a STRING function type . The code is long so I took a piece of it and here it is:

    string padIfNeeded (string ans)
    {
    if ( ans == "" )
    {
    return "";
    }
    return " " + ans;
    }

    string translateHundred (int hundred_chunk)
    {
    // handle special cases in the teens
    if ( hundred_chunk < 20 ) {
    return num_to_text[ hundred_chunk ];
    }
    int tens = hundred_chunk / 10;
    int ones = hundred_chunk % 10;
    return tens_to_text[ tens ] + padIfNeeded( num_to_text[ ones ] );
    }


    string translateThousand (int thousand_chunk)
    {
    if ( thousand_chunk < 100 )
    {
    return translateHundred( thousand_chunk );
    }
    else
    {
    int hundreds = thousand_chunk / 100;
    int hundred_chunk = thousand_chunk % 100;
    return num_to_text[ hundreds ] + " hundred" + padIfNeeded( translateHundred( hundred_chunk ) );
    }
    }

    I know that the string type function turn a string but I could not find this function type in c/c++ manual or in an article or even in Google so here are my questions
    1)how this function (string type function) works with examples and if possible articles , videos or manuals in the internet
    2)

    #include <string>
    #include <iostream>





    using namespace std;

    string show (string a )
    {
    printf("%s\n" , a);
    }
    int main()
    {

    string c = " hello world";

    foo(c);
    }


    the compiler gives an error:cannot pass objects of non-POD type `struct std::string' through `... '; call will abort at runtime



    2)why the compiler give such an error and how to correct the code using string type function??
  • Jun 17, 2014, 02:41 AM
    mohini singh
    Getch() in c basically is a predefined function of conio.h header file in c.
    It is get character with echo off.it means whenever we use getch() it will take a character and will not display it on console.
    It is myth that getch() is use to hold screen... actually it is use at the end of program just before return because theprogram will terminate when the getch() statement is executed when we hit a character or enter getch() takes it and then the prgram is terminated.

  • All times are GMT -7. The time now is 12:31 PM.