Solved

_printf error with visual c 1.52

Posted on 1998-05-31
4
460 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

895 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

12 Experts available now in Live!

Get 1:1 Help Now