- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- HPUX11 fgets() warning
Operating System - HP-UX
1752790
Members
6153
Online
108789
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2001 09:23 AM
03-22-2001 09:23 AM
HPUX11 fgets() warning
Can some one shed some light on this problem for me.
While compling the following code on HPUX11 unix platform.
1 #include
2
3 void main()
4 {
5 FILE *infile;
6
7 static unsigned char buf[1024];
8
9 infile = fopen("test.txt", "r");
10
11 while (fgets(buf,80,infile) != NULL);
12 {
13 fputs(buf, stdout);
14 }
15 }
I get the following erros:
cc: "temp.c", line 11: warning 604: Pointers are not
assignment-compatible.
cc: "temp.c", line 11: warning 563: Argument #1 is not the correct type.
cc: "temp.c", line 13: warning 604: Pointers are not
assignment-compatible.
cc: "temp.c", line 13: warning 563: Argument #1 is not the correct type.
I went to HP site and check on the sytax for HPUX11 on fgets at:
http://devresource.hp.com/STKL/man/11.00/gets_3s.html
I can not see any problem with the code and it runs with no problems.
Thanks in advance for your help Marty
While compling the following code on HPUX11 unix platform.
1 #include
2
3 void main()
4 {
5 FILE *infile;
6
7 static unsigned char buf[1024];
8
9 infile = fopen("test.txt", "r");
10
11 while (fgets(buf,80,infile) != NULL);
12 {
13 fputs(buf, stdout);
14 }
15 }
I get the following erros:
cc: "temp.c", line 11: warning 604: Pointers are not
assignment-compatible.
cc: "temp.c", line 11: warning 563: Argument #1 is not the correct type.
cc: "temp.c", line 13: warning 604: Pointers are not
assignment-compatible.
cc: "temp.c", line 13: warning 563: Argument #1 is not the correct type.
I went to HP site and check on the sytax for HPUX11 on fgets at:
http://devresource.hp.com/STKL/man/11.00/gets_3s.html
I can not see any problem with the code and it runs with no problems.
Thanks in advance for your help Marty
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2001 01:06 PM
03-22-2001 01:06 PM
Re: HPUX11 fgets() warning
Marty,
The fgets() and fputs() functions expect a pointer to a (signed) char, not a pointer to an unsigned char. This doesn't make much difference to your program, but is sufficient to cause the compiler to generate a warning. You can eliminate these warnings by changing your declaration of "buf" to:
static char buf[1024];
Incidentially, the program as you posted it will actually print nothing, because the line:
while( fgets( buf, 80, infile ) != NULL ) ;
will simply read all of the lines of the infile and do nothing with them. (Ie, you should remove the semicolon at the end of the line).
I hope this helps.
The fgets() and fputs() functions expect a pointer to a (signed) char, not a pointer to an unsigned char. This doesn't make much difference to your program, but is sufficient to cause the compiler to generate a warning. You can eliminate these warnings by changing your declaration of "buf" to:
static char buf[1024];
Incidentially, the program as you posted it will actually print nothing, because the line:
while( fgets( buf, 80, infile ) != NULL ) ;
will simply read all of the lines of the infile and do nothing with them. (Ie, you should remove the semicolon at the end of the line).
I hope this helps.
I think, therefore I am... I think!
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP