I wrote following program:
#include <stdio.h>
main()
{
FILE *file;
file=fopen(d:\readme.txt,"r");
if (file==NULL)
printf("fuck it's not working");
else
printf("finaly");
}
My problem is that the only programs' result is : "fuck it's not working"
What do I wrong? 19 31591
In article <91**************************@posting.google.com >, Taras wrote: I wrote following program:
#include <stdio.h>
main()
int main(void)
{ FILE *file;
file=fopen(d:\readme.txt,"r"); if (file==NULL) printf("fuck it's not working"); else printf("finaly");
fclose(file);
return 0;
}
My problem is that the only programs' result is : "fuck it's not working"
I doubt it's even that, you have a syntax error on the line
file=fopen(d:\readme.txt,"r");
Try writing it as
file = fopen("d:/readme.txt", "r");
instead, or escape the backslash:
file = fopen("d:\\readme.txt", "r");
--
Andreas Kähäri
"Taras" <te*****@o2.pl> wrote in message
news:91**************************@posting.google.c om... I wrote following program:
#include <stdio.h>
main() { FILE *file;
file=fopen(d:\readme.txt,"r");
file=fopen("d:\readme.txt", "r");
if (file==NULL) printf("fuck it's not working"); else printf("finaly"); }
My problem is that the only programs' result is : "fuck it's not working" What do I wrong?
"Fao, Sean" <en**********@yahoo.comI-WANT-NO-SPAM> wrote in message
news:rK********************@news1.news.adelphia.ne t... "Taras" <te*****@o2.pl> wrote in message news:91**************************@posting.google.c om... I wrote following program:
#include <stdio.h>
main() { FILE *file;
file=fopen(d:\readme.txt,"r");
file=fopen("d:\readme.txt", "r");
if (file==NULL) printf("fuck it's not working"); else printf("finaly");
/* Oops, I missed this */
fclose(file);
return 0;
}
"Taras" <te*****@o2.pl> wrote in message
news:91**************************@posting.google.c om... I wrote following program:
#include <stdio.h>
main() { FILE *file;
file=fopen(d:\readme.txt,"r"); if (file==NULL) printf("fuck it's not working"); else printf("finaly"); }
Ok, this is the last time that I fix code when I've only had 2 hours of
sleep. Ignore everything I've written up to this point and read what the
other poster wrote.
<no@no.invalid> wrote in message
news:20***********************@mail.zedz.net... Do we *have* to point out the int main(void) return 0 etc things ?
No, of course you don't have to.
But those who want to convey correctness will.
I seems that many instructors don't, through
ignorance, apathy, or whatever.
-Mike
"no@no.invalid" <no@no.invalid> wrote in
news:20***********************@mail.zedz.net on Sat 04 Oct 2003
01:11:21p: Do we *have* to point out the int main(void) return 0 etc things ?
Yes. Any other declaration for main() is nonstandard and is erroneous. For
example, void main() is incorrect despite its popularity among the less
intelligent of the book and tutorial writers.
Andreas Kahari <ak*******@freeshell.org> wrote in message news:<sl**********************@mx.freeshell.org>.. . In article <91**************************@posting.google.com >, Taras wrote: I wrote following program:
#include <stdio.h>
main()
int main(void)
{ FILE *file;
file=fopen(d:\readme.txt,"r"); if (file==NULL) printf("fuck it's not working"); else printf("finaly");
fclose(file); return 0;
}
My problem is that the only programs' result is : "fuck it's not working"
I doubt it's even that, you have a syntax error on the line
file=fopen(d:\readme.txt,"r");
Try writing it as
file = fopen("d:/readme.txt", "r");
instead, or escape the backslash:
file = fopen("d:\\readme.txt", "r");
Thank you , now it at last writes finally!
In article <91**************************@posting.google.com >,
Taras wrote: Andreas Kahari <ak*******@freeshell.org> wrote in message news:<sl**********************@mx.freeshell.org>.. .
[cut] Try writing it as
file = fopen("d:/readme.txt", "r");
Thank you , now it at last writes finally!
Reads, I hope.
--
Andreas Kähäri
Andreas Kahari <ak*******@freeshell.org> scribbled the following: In article <91**************************@posting.google.com >, Taras wrote: Andreas Kahari <ak*******@freeshell.org> wrote in message news:<sl**********************@mx.freeshell.org>.. . [cut] Try writing it as
file = fopen("d:/readme.txt", "r");
Thank you , now it at last writes finally!
Reads, I hope.
No, "writes" is correct. The OP's code:
---------------------------------------------------------------
#include <stdio.h>
main()
{
FILE *file;
file=fopen(d:\readme.txt,"r");
if (file==NULL)
printf("fuck it's not working");
else
printf("finaly");
}
----------------------------------------------------------------
See the last printf() statement.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
In article <bl**********@oravannahka.helsinki.fi>, Joona I Palaste wrote: Andreas Kahari <ak*******@freeshell.org> scribbled the following: In article <91**************************@posting.google.com >, Taras wrote: Andreas Kahari <ak*******@freeshell.org> wrote in message
[cut] file = fopen("d:/readme.txt", "r"); Thank you , now it at last writes finally! Reads, I hope. No, "writes" is correct. The OP's code:
[cut] See the last printf() statement.
No, that is possibly "displays", but I was concentrating more on
the fopen(), with the "r" mode.
--
Andreas Kähäri
Andreas Kahari <ak*******@freeshell.org> writes: In article <bl**********@oravannahka.helsinki.fi>, Joona I Palaste wrote: Andreas Kahari <ak*******@freeshell.org> scribbled the following: In article <91**************************@posting.google.com >, Taras wrote: Andreas Kahari <ak*******@freeshell.org> wrote in message [cut]> file = fopen("d:/readme.txt", "r"); Thank you , now it at last writes finally! Reads, I hope. No, "writes" is correct. The OP's code: [cut] See the last printf() statement.
No, that is possibly "displays", but I was concentrating more on the fopen(), with the "r" mode.
You were concentrating wrong. And recall that the C standard has
no notion of "displays". He said what he meant, but he should
have used quotations, and the code's spelling should have been
fixed.
...now it at last writes, "finally"!
-Micah
"Fao, Sean" <en**********@yahoo.comI-WANT-NO-SPAM> wrote in message
news:rK********************@news1.news.adelphia.ne t... "Taras" <te*****@o2.pl> wrote in message news:91**************************@posting.google.c om... I wrote following program:
#include <stdio.h>
main() { FILE *file;
file=fopen(d:\readme.txt,"r");
file=fopen("d:\readme.txt", "r");
file = fopen("d:\\readme.txt", "r");
:-)
"Micah Cowan" <mi***@cowan.name> wrote in message
news:m3************@localhost.localdomain...
.... You were concentrating wrong. And recall that the C standard has no notion of "displays".
5.2.2 Character display semantics
It does have *some* notion.
--
Peter
August Derleth <li*****************@onewest.net> wrote in message news:<Xn**********************************@63.223. 6.93>... Yes. Any other declaration for main() is nonstandard and is erroneous.
unless, of course, its documented by the implementation.
For example, void main() is incorrect despite its popularity among the less intelligent of the book and tutorial writers.
goose,
sometimes it is documented ;-)
In <ff**************************@posting.google.com > ru**@webmail.co.za (goose) writes: August Derleth <li*****************@onewest.net> wrote in message news:<Xn**********************************@63.223. 6.93>... Yes. Any other declaration for main() is nonstandard and is erroneous.
unless, of course, its documented by the implementation.
And if the implementation in question claims C99 conformance. In C89,
it doesn't make any difference whether the implementation documents other
main intefaces or not.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de Da*****@cern.ch (Dan Pop) wrote in message news:<bl**********@sunnews.cern.ch>... In <ff**************************@posting.google.com > ru**@webmail.co.za (goose) writes:
August Derleth <li*****************@onewest.net> wrote in message news:<Xn**********************************@63.223. 6.93>... Yes. Any other declaration for main() is nonstandard and is erroneous.
unless, of course, its documented by the implementation.
And if the implementation in question claims C99 conformance. In C89, it doesn't make any difference whether the implementation documents other main intefaces or not.
I'm not sure i follow. the c99 standard says "or some other
implementation-defined manner" after stating the legal return
values and arguments. does the c89 standard say differently with
regard to this ? I would like to see a quote (or perhaps a link).
tia
goose,
(I dont have the c89 standard, i *do* have c99 and the n869 file)
On Sat, 04 Oct 2003 08:55:51 -0700, Taras wrote: I wrote following program:
#include <stdio.h>
main() { FILE *file;
file=fopen(d:\readme.txt,"r"); if (file==NULL) printf("fuck it's not working"); else printf("finaly"); }
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *file;
file = fopen ("d:/reame.txt", "r");
if (file == NULL)
printf ("f*** it's not working\n");
else {
printf ("finally\n");
fclose (f);
}
return EXIT_SUCCESS;
}
I'd say \n is nice if you wish to have portable output, also EXIT_SUCCESS
is far better than guessing some popular value.
Regards
Zygmunt Krynicki
In <ff**************************@posting.google.com > ru**@webmail.co.za (goose) writes: Da*****@cern.ch (Dan Pop) wrote in message news:<bl**********@sunnews.cern.ch>... In <ff**************************@posting.google.com > ru**@webmail.co.za (goose) writes:
>August Derleth <li*****************@onewest.net> wrote in message news:<Xn**********************************@63.223. 6.93>... >> >> Yes. Any other declaration for main() is nonstandard and is erroneous. > >unless, of course, its documented by the implementation. And if the implementation in question claims C99 conformance. In C89, it doesn't make any difference whether the implementation documents other main intefaces or not.
I'm not sure i follow. the c99 standard says "or some other implementation-defined manner" after stating the legal return values and arguments. does the c89 standard say differently with regard to this ?
Yes. Otherwise, I wouldn't have mentioned C99 conformance.
I would like to see a quote (or perhaps a link).
2.1.2.2 Hosted environment
A hosted environment need not be provided, but shall conform to the
following specifications if present.
"Program startup"
The function called at program startup is named main. The
implementation declares no prototype for this function. It can be
defined with no parameters:
int main(void) { /*...*/ }
or with two parameters (referred to here as argc and argv, though any
names may be used, as they are local to the function in which they are
declared):
int main(int argc, char *argv[]) { /*...*/ }
If they are defined, the parameters to the main function shall obey
the following constraints:
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
"Zygmunt Krynicki" <zyga@_CUT_2zyga.MEdyndns._OUT_org> wrote in message news:<pan.2003.10.07.21.10.53.948441@_CUT_2zyga.ME dyndns._OUT_org>... On Sat, 04 Oct 2003 08:55:51 -0700, Taras wrote:
I wrote following program:
#include <stdio.h>
main() { FILE *file;
file=fopen(d:\readme.txt,"r"); if (file==NULL) printf("fuck it's not working"); else printf("finaly"); } #include <stdio.h> #include <stdlib.h>
int main(void) { FILE *file; file = fopen ("d:/reame.txt", "r");
file = fopen ("d:/readme.txt", "r"); /* :-) */
if (file == NULL)
{ printf ("f*** it's not working\n");
return EXIT_FAILURE;
} else {
^^^^^^ <--- no need for that
printf ("finally\n"); fclose (f); }
^ <--- or that
return EXIT_SUCCESS; }
I'd say \n is nice if you wish to have portable output,
or even, any output :-)
also EXIT_SUCCESS is far better than guessing some popular value.
and returning a non-success value is better than
*always* returning EXIT_SUCCESS, even on failure.
goose, This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ming |
last post by:
When I use fopen on the URL:
fopen("http://home.pchome.com.tw/world/qoo4ko/110.jpg";, "r")
I would get the following error message:
-----------Error Message------------
Warning: fopen():...
|
by: typingcat |
last post by:
Is it possible to read another web page in PHP?
If is ASP.NET, the code would be
------------
WebRequest req=WebRequest.Create("http://www.microsoft.com");
WebResponse res=req.GetResponse();...
|
by: git_cs |
last post by:
Hey, guys and gals
Somedays ago, I had asked for the DES algorithm in C language.
Although I have written the algorthim in C myself, I am facing a
peculiar problem, which I hope some of u guys and...
|
by: Grocery Clerk |
last post by:
I know open() returns a file descriptor and fopen() returns a pointer
to FILE. The question is, when do I use fopen() and when do I use
open()? Could someone give me an example when to use one...
|
by: Sathyaish |
last post by:
If fopen fails, is there a way to know why?
|
by: Blue |
last post by:
Hi ,
Can any one please let me explain me the diffrences between "open"/
"fopen" or "read"/"fread" or "write/fwrite".
I know that "open" /"read" / "write" are system calls and "fopen"...
|
by: pjlsr |
last post by:
It's close to twenty years since I used the C language and at that time
I was doing only floating point computational work, nothing with
strings or reading files. I tried to use fopen in the...
|
by: Jae |
last post by:
Real(const string &fileName)
{
FILE * myInputFile = fopen(fileName, "rt");
.....
fclose(myInputFile);
|
by: Julia |
last post by:
Hi, there,
I am trying to append a binary file by using:
FILE *strean;
stream = fopen( "c:\temp.dat", "ba+" ));
Is there a way that I can check if the file exists or not before
fopen,...
|
by: subramanian100in |
last post by:
Consider the following program:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv)
{
if (argc != 2)
{
printf("Usage: <program-name<text-file>\n");
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |