1 Replies - 1526 Views - Last Post: 17 March 2013 - 04:07 PM Rate Topic: -----

#1 shahaan_reptile  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 17-March 13

not showing errors but code isnt working

Posted 17 March 2013 - 03:46 PM

couldn't find any errors but still the code is not working.
And the Question for creating this code is
"Is it possible to make a XxY size postcard from AxB size paper?"

#include <vcl.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
#pragma hdrstop
using namespace std;

#pragma argsused
int main(int argc, char* argv[])
    int X, Y, A, B;
    cout<<"Input A" << "\n";
    cout<<"Input B" << "\n";
    cout<<"Input X" << "\n";
    cout<<"Input Y" << "\n";
    cin >> A;
    cin >> B;
    cin >> X;
    cin >> Y;
    if((X*Y)< (A*B)/>){
else {
while (!kbhit());
return 0;

This post has been edited by JackOfAllTrades: 18 March 2013 - 03:11 AM
Reason for edit:: Added code tags

Is This A Good Question/Topic? 0
  • +

Replies To: not showing errors but code isnt working

#2 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6544
  • View blog
  • Posts: 26,526
  • Joined: 12-December 12

Re: not showing errors but code isnt working

Posted 17 March 2013 - 04:07 PM

I suspect that it works but finishes immediately as there is still a character left in the input buffer when you call kbhit(). You need to flush the input buffer before calling kbhit(). I'm not sure which method to recommend for this - possibly cin.flush(). Someone else might advise.

Possibly cin.ignore(INT_MAX);.

Please wrap your code in code-tags, it tells you how to do this directly in the area where you are typing your post. Use the Preview button until it is correct (this also accounts for the smiley appearing in your 'code').
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1