NO

Author Topic: putw unresolved external.  (Read 5730 times)

juice

  • Guest
putw unresolved external.
« 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'."

Code: [Select]
#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);
}


Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: putw unresolved external.
« Reply #1 on: December 20, 2011, 05:28:47 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

juice

  • Guest
Re: putw unresolved external.
« Reply #2 on: December 20, 2011, 05:34:53 AM »

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: putw unresolved external.
« Reply #3 on: December 20, 2011, 05:39:37 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...
Quote
http://www.mkssoftware.com/docs/man3/putw.3.asp
That's a Unix C reference, not much good for programming under Windows...

Ralf

juice

  • Guest
Re: putw unresolved external.
« Reply #4 on: December 20, 2011, 06:00:12 AM »
is their any function in pelles C which writes an integer into a file, like putw..

CommonTater

  • Guest
Re: putw unresolved external.
« Reply #5 on: December 20, 2011, 09:19:55 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.

« Last Edit: December 20, 2011, 09:24:50 AM by CommonTater »

juice

  • Guest
Re: putw unresolved external.
« Reply #6 on: December 20, 2011, 10:08:47 AM »
It does not recognize getch() either..

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

CommonTater

  • Guest
Re: putw unresolved external.
« Reply #7 on: December 20, 2011, 10:13:01 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.

 

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: putw unresolved external.
« Reply #8 on: December 20, 2011, 05:17:15 PM »
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

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2107
Re: putw unresolved external.
« Reply #9 on: December 20, 2011, 05:51:21 PM »
Code: [Select]
fwrite(&number, 1, sizeof(int), fp);
May the source be with you

net2011

  • Guest
Re: putw unresolved external.
« Reply #10 on: December 23, 2011, 04:47:37 AM »
Hi. You might also try _getch(); instead of getch(); . It worked for me.