putw unresolved external.

Started by juice, December 20, 2011, 05:19:19 AM

Previous topic - Next topic

juice

the following code when executed using pelles C reports an error "POLINK: error: Unresolved external symbol '_putw'."


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
int main()
{
    FILE *fp,*ft;
int number; char c;

fp=fopen("random","w");

scanf("%d",&number);
while(number!=-1)
{
putw(number,fp);
scanf("%d",&number);
}

number = ftell(fp);
printf("\n%d",number);
}


Bitbeisser

Quote from: juice on December 20, 2011, 05:19:19 AM
the following code when executed using pelles C reports an error "POLINK: error: Unresolved external symbol '_putw'."
No surprise, as none of the include files you list has a definition for a function called putw ()...
And there isn't such a function with that name in the whole Pelle's C.

Where did you get this sample from?

Ralf


Bitbeisser

Quote from: juice on December 20, 2011, 05:34:53 AM
it works under MSVC 2010...
Well, Pelle's C doesn't have a function for a word/int sized output to a stream. Only putc() and putwc() for char and wide char and puts() for strings.
Not sure if that works in in Visual C++ because it might be a C++ function...
Quotehttp://www.mkssoftware.com/docs/man3/putw.3.asp
That's a Unix C reference, not much good for programming under Windows...

Ralf

juice

is their any function in pelles C which writes an integer into a file, like putw..

CommonTater

#5
Quote from: juice on December 20, 2011, 06:00:12 AM
is their any function in pelles C which writes an integer into a file, like putw..

Did you look in the help file?
(Hint: If you put your cursor on the keyword and hit F1... if it doesn't come up, Pelles C doesn't support it)

I'm thinking fprintf() is your best bet.


juice

It does not recognize getch() either..

"POLINK: error: Unresolved external symbol '_getch'."

CommonTater

Quote from: juice on December 20, 2011, 10:08:47 AM
It does not recognize getch() either..

"POLINK: error: Unresolved external symbol '_getch'."

#include <conio.h>

Project -> Project Options -> Compiler -> Define Compatibility Names = checked.

But be warned... conio  and getch() are not standard C... as clearly marked in the help file.


Bitbeisser

Quote from: CommonTater on December 20, 2011, 09:19:55 AM
Quote from: juice on December 20, 2011, 06:00:12 AM
is their any function in pelles C which writes an integer into a file, like putw..
I'm thinking fprintf() is your best bet.
Actually, not quite.

putw() would put the binary representation of the word/integer into the file stream, while fprintf() would put a "textual" representation into the filestream. Not sure if that's what the OP intendeds...  :-\

As mentioned before, Pelle's C only supports putc() for a byte sized object, which could be used instead or write your own replacement for putw(), but then you might have to pay attention to the byte order/endianess...

Ralf

TimoVJL

fwrite(&number, 1, sizeof(int), fp);
May the source be with you

net2011

Hi. You might also try _getch(); instead of getch(); . It worked for me.