473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

fprintf problem

fprintf just is not working. I am using PHP Version 4.3.9. Whatever I
do fprintf just fails.

For example:

fwrite($Handle, 'A1');
fprintf($Handle, 'A2);

The first line always works, the second always fails. Likewise any
other example.

Suggestions?

Feb 13 '07 #1
4 2699
On 13 Feb, 22:13, grim...@blackbelts.co.uk wrote:
fprintf($Handle, 'A2);
Should be fprintf($Handle, 'A2');

That's just a typo not the problem!

Feb 13 '07 #2
gr*****@blackbelts.co.uk wrote:
fprintf just is not working. I am using PHP Version 4.3.9. Whatever I
do fprintf just fails.

For example:

fwrite($Handle, 'A1');
fprintf($Handle, 'A2);

The first line always works, the second always fails. Likewise any
other example.

Suggestions?
'A2' isn't a format string?
Feb 13 '07 #3
Paul Lautman wrote:
gr*****@blackbelts.co.uk wrote:
>fprintf just is not working. I am using PHP Version 4.3.9. Whatever I
do fprintf just fails.

For example:

fwrite($Handle, 'A1');
fprintf($Handle, 'A2);

The first line always works, the second always fails. Likewise any
other example.

Suggestions?

'A2' isn't a format string?

No, that's not the issue, but unless he needs to use printed
formatting, there's no real reason to use fprintf over fwrite.

@Original Poster: how does fprintf fail, do you get an error, or is
the input not written how you expected? You need to give details, or
no one can help you.

In the meantime, try reading the manual: <http://php.net/fprintf>
Feb 14 '07 #4
On 14 Feb, 03:29, Curtis <zer0d...@verizon.netwrote:
Paul Lautman wrote:
grim...@blackbelts.co.uk wrote:
fprintf just is not working. I am using PHP Version 4.3.9. Whatever I
do fprintf just fails.
For example:
fwrite($Handle, 'A1');
fprintf($Handle, 'A2);
The first line always works, the second always fails. Likewise any
other example.
Suggestions?
'A2' isn't a format string?

No, that's not the issue, but unless he needs to use printed
formatting, there's no real reason to use fprintf over fwrite.

@Original Poster: how does fprintf fail, do you get an error, or is
the input not written how you expected? You need to give details, or
no one can help you.

In the meantime, try reading the manual: <http://php.net/fprintf>- Hide quoted text -

- Show quoted text -
It gives an run time error because none of the statements below it are
executed.

I got round it by using sprintf (exactly the same apart from the
different first argument) into a string, and then fwrite.

Rob

Feb 19 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Arti Potnis | last post by:
Hi, I have an application with a function "myfunction" that opens a file and writes to it using fprintf. This application runs on a unix (sun solaris 5.8) system. I connect to this application...
2
by: hpy_awad | last post by:
formatting float variables to fprintf has error to my writing to output file called rental and I do not the reason that a rabish is written to the file instead of the actual input screen values ? ...
6
by: hpy_awad | last post by:
I am writing stings ((*cust).name),((*cust).address)to a file using fgets but rabish is being wrote to that file ? Look to my source please and help me finding the reason why this rabish is being...
8
by: Smegly | last post by:
Hi, I'm confused about a situation i have .. fprintf works in one function, but not in the other . . This is my part of my code for the two functions .. void customer(FILE *fin, FILE...
17
by: G Patel | last post by:
E. Robert Tisdale wrote: > > int main(int argc, char* argv) { > quad_t m = {0, 1, 2, 3}; > int r; > fprintf(stdout, "m = ("); > for (size_t...
7
by: jchludzinski | last post by:
I tryin' to print out a string with a variable number of blanks/spaces preceding the string. I know that if I use: fprintf( stdout, "%12s", string ); I get 12 blanks preceding 'string'. If I...
1
by: samac | last post by:
Hi all, Need some help in c. I have not been in programming for ten years. Here is my problem: From main(), I call a function - a_function(). In a_function(), I call another function...
16
by: Prayag Narula | last post by:
Hi, I want to redefine fprintf for debugging purposes. That is I want that all the output that is going to the stdout should be logged in a file. I tried something like #define fprintf...
11
by: David Mathog | last post by:
In the beginning (Kernighan & Ritchie 1978) there was fprintf, and unix write, but no fwrite. That is, no portable C method for writing binary data, only system calls which were OS specific. At...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.