473,388 Members | 1,468 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,388 software developers and data experts.

about c/c++ 问题!

Hello everyone!
Today, I programed a program with c,but regrettly i didn't success;
My programe is as follows:

#include <stdio.h>
int main()
{
FILE* pFile ;

pFile = fopen("yuya.txt","wt");

if(pFile != NULL)
fputs("fopen is a function!",pFile);

fclose(pFile);

pFile = fopen("yuya1.pdf","w+");

if(pFile != NULL)
fputs("zhangyuya is a student !",pFile);
fclose(pFile);

return 0;
}

Problem: i create a PDF file successfully,but i don't open it with
adobe reader,as though i write many text in it, but i read its content
which i write with VC IDE,
WHY?

Mar 9 '06 #1
4 1879
yuyazhang wrote:

To help you get better responses from USENET, please Google for the FAQ for
this newsgroup. You might find things like...

- how to write a good subject line
- there is no language C/C++
- questions about C get the best answer on news:comp.lang.c
- C++ systems are easier to use, and you should learn them first

You may have a professor who does not understand the last one. Or you may
have signed up for a C class, not C++.

Here's your answer:
pFile = fopen("yuya1.pdf","w+");


It takes more than a .PDF extension to make a Portable Document Format
program. Open a real PDF file with Notepad, or the VC IDE, and look at it.
It is a binary format, not text, and it is compressed and delimited in ways
you should not yet worry about.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Mar 9 '06 #2
yuyazhang wrote:
Hello everyone!
Today, I programed a program with c,but regrettly i didn't success;
My programe is as follows:

#include <stdio.h>
int main()
{
FILE* pFile ;

pFile = fopen("yuya.txt","wt");

if(pFile != NULL)
fputs("fopen is a function!",pFile);

fclose(pFile);

pFile = fopen("yuya1.pdf","w+");

if(pFile != NULL)
fputs("zhangyuya is a student !",pFile);
fclose(pFile);

return 0;
}

Problem: i create a PDF file successfully,but i don't open it with
adobe reader,as though i write many text in it, but i read its content
which i write with VC IDE,
WHY?


You just gave it a name ending with .pdf. That is not enough to make it
a real PDF file. You just have a text file with the wrong extension.

If you want to create a real PDF file, use "wb" (binary mode), and start
learning about the PDF file format.

Download (3174K)
Portable Document Format Reference Manual Version 1.3
March 11, 1999 (Acrobat) [Adobe]
http://www.wotsit.org/download.asp?f=pdfspec

You may find it easier to output PostScript, as that is a simple text
format, and use an external program (ps2pdf) to convert that to a PDF.

--
Simon.
Mar 10 '06 #3
Thank you ! i can understand what you say,mainly i find it is few
pepole on news:comp.lang.c !

Mar 10 '06 #4
Thank you for giving me a lot of advice ! thank you !

Mar 10 '06 #5

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

Similar topics

1
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
8
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
77
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: eScrewDotCom | last post by:
www.eScrew.com eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is...
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
0
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
7
by: Edward Yang | last post by:
A few days ago I started a thread "I think C# is forcing us to write more (redundant) code" and got many replies (more than what I had expected). But after reading all the replies I think my...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.