Results 1 to 2 of 2

Thread: How to run cosol based application in Qt creator

  1. #1
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to run cosol based application in Qt creator

    Hi ALl,
    I cannot run consol based application using Qt creator. Plz tell me if my procedure is wrong. Below also i've pasted snipset of my code.

    1. open new project
    2. select Qt console based application.
    3. write the code.

    Its not recognising std library functions.

    Qt Code:
    1. //#include <QtCore/QCoreApplication>
    2. #include <iostream>
    3.  
    4. using namespace std;
    5. //int main(int argc, char *argv[])
    6. //{
    7. // QCoreApplication a(argc, argv);
    8. //
    9. // return a.exec();
    10. //}
    11.  
    12.  
    13.  
    14. #include <stdio.h>
    15.  
    16. void dec_bin(int number);
    17.  
    18. int main(void)
    19. {
    20. int input = 0;
    21.  
    22. printf("Digit (0-255): ");
    23. scanf("%d", &input);
    24.  
    25. (input >= 0) && (input < 256) ? dec_bin(input) : std::exit(1);
    26.  
    27. return 0;
    28. }
    29.  
    30. void dec_bin(int number)
    31. {
    32. int x, y;
    33. x = y = 0;
    34.  
    35. for(y = 7; y >= 0; y--)
    36. {
    37. x = number / (1 << y);
    38. number = number - x * (1 << y);
    39. printf("%d", x);
    40. }
    41.  
    42. printf("\n");
    43. }
    To copy to clipboard, switch view to plain text mode 


    Thank you all.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  2. #2
    Join Date
    Oct 2009
    Posts
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to run cosol based application in Qt creator

    Hello,

    std::exit is in cstdlib. You must include this.
    Your code is nearly pure C. Do you want to write C or C++?

Similar Threads

  1. Replies: 3
    Last Post: 28th February 2010, 08:10
  2. Replies: 1
    Last Post: 2nd November 2009, 20:35
  3. Deploying Qt 4.4 based Mac application
    By Ian_001 in forum Installation and Deployment
    Replies: 0
    Last Post: 31st October 2008, 15:13
  4. Qt plug-in for GLib event loop based application
    By profoX in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2008, 14:27
  5. Replies: 2
    Last Post: 27th June 2007, 10:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.