Solved

_printf error with visual c 1.52

Posted on 1998-05-31
4
454 Views
Last Modified: 2013-12-03
What causes this link problem ( _printf ) with Visual C 1.52 in this windows project & how can it be solved ?

#include <stdio.h>
#include <windows.h>

void main()
{
  printf("This is just a test");
}

Linking...

TRY.OBJ(c:\project\vc-c1_de.kit\vcc\vcc\try.c) : error L2029: '_printf' : unresolved external

 LINK returned error code 2.
4.EXE - 1 error(s), 0 warning(s)

0
Comment
Question by:sector
  • 3
4 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1405500
printf() needs a console to print to and Win16 does not support consoles.  Compile your project as QiuckWin (or something similar).
0
 

Author Comment

by:sector
ID: 1405501
i can't compile my program as a quickWindow application
because it is a CGI .

what other alternatives do i have ???
0
 
LVL 11

Accepted Solution

by:
alexo earned 20 total points
ID: 1405502
OK, first thing first: Native Win16 applications cannot use printf() for lack of a console.

Options:

1. Compile as a QuickWin application.  It "maps" the stdio to a window that simulates a console.  I have no idea why a CGI cannot be a QuickWin application, but then, I have no idea how a CGI is different from a "normal" application.

2. Compile it as a DOS application.  Obviously all functionality provided by Windows will be unavailable.  A DOS program can run under windows without a problem.

3. Move to Windows95/98/NT and compile the program as a console application.

4. Create a window and a DC in your application and use TextOut() APIs for output.

5. Create an edit box in your application and use EM_SETSEL and EM_REPLACESEL messages to display output.

To summarize:  Either compile for a platform that supports a console (QuickWin, Win32 or DOS) or manage the output yourself using Win16 APIs or controls.

0
 
LVL 11

Expert Comment

by:alexo
ID: 1405503
And the autograder hits again!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now