Help a brainlet out

Help a brainlet out.
How the fuck am I supposed to open files in C?

Other urls found in this thread:

tutorialsapoint.com/c_standard_library/c_function_fopen.htm
tutorialspoint.com/c_standard_library/c_function_fopen
twitter.com/NSFWRedditImage

>>>/google/
>>>/duckduckgo/
>>>/startpage/
your choice

like run them?

after you compile I know in c++ it's
./filename

Mandatory lol.
You use open()

That's for executing binaries in general, and I think OP means how to read/write from a file

Read K&R ffs

alright, i'm just gonna ask you what i'm supposed to do because i have to do this for an assignment but i have no fucking clue what to do
i'm supposed to create a text file that contains one integer value with no file extension using emacs in a linux terminal
then, i'm supposed to write a program that opens that file, reads the integer value, and prints it to the console

*YOU* are full of bullshit.

C++ is a horrible language. It's made more horrible by the fact that a lot
of substandard programmers use it, to the point where it's much much
easier to generate total and utter crap with it.
In other words: the choice of C is the only sane choice. I know Miles
Bader jokingly said "to piss you off", but it's actually true. I've come
to the conclusion that any programmer that would prefer the project to be
in C++ over C is likely a programmer that I really *would* prefer to piss
off, so that he doesn't come and screw up any project I'm involved with.

C++ leads to really really bad design choices. You invariably start using
the "nice" library features of the language like STL and Boost and other
total and utter crap, that may "help" you program, but causes:

- infinite amounts of pain when they don't work (and anybody who tells me
that STL and especially Boost are stable and portable is just so full
of BS that it's not even funny)

- inefficient abstracted programming models where two years down the road
you notice that some abstraction wasn't very efficient, but now all
your code depends on all the nice object models around it, and you
cannot fix it without rewriting your app.

In other words, the only way to do good, efficient, and system-level and
portable C++ ends up to limit yourself to all the things that are
basically available in C.

So I'm sorry, but for something like git, where efficiency was a primary objective, the "advantages" of C++ is just a huge mistake. The fact that we also piss off people who cannot see that is just a big additional
advantage.

They use a "real database". They use "nice object-oriented libraries".
They use "nice C++ abstractions". And quite frankly, as a result of all
these design decisions that sound so appealing to some CS people, the end
result is a horrible and unmaintainable mess.

But I'm sure you'd like it more than git.

fopen() is the superior API

copy and paste the code snippet from some documentation site
that's how eveyone else does it

t. Linus

tutorialsapoint.com/c_standard_library/c_function_fopen.htm

fuk, messed up the link
tutorialspoint.com/c_standard_library/c_function_fopen

How so?

Why are you coding in C and not C++?

C++ style
#include
#include
using namespace std;

int main () {
fstream myfile;
myfile.open ("example.txt");
if (myfile.is_open())
{
myfile

Unix style
#include
#include
#include
extern int errno;

int main(){

int fd = open("example.txt", O_RDWR | O_CREAT);
char buf1[13] = "hello faggot";
if (fd ==-1)
{
// print which type of error have in a code
printf("Error Number % d\n", errno);
exit(1);
}
write(fd, buf1, strlen(buf1));
close(fd);
return 0;
}

open() is non-buffered and POSIX-only
fopen() is buffered and available in any implementation of C

C style
int main()
{
FILE *fptr = fopen("example.txt", "w");
const char[7] OP = "faggot";
if(fptr == NULL)
{
printf("Error!");
exit(1);
}
fprintf(fptr, "OP is a %s\n", OP);

fclose(fptr);
return 0;
}

>const char[7] OP

const char OP[7]

>using a OOP language for non OOP projects

>implying C++ is oop

>learning C
Don't you know that JavaScript is the future of all programming?

#include

int main(void)
{
int num;
FILE *fag = fopen("FAGGOT", "r");

if (NULL == fag) {
fputs("OP is a faggot\n", stderr);
return -1;
}
if (1 > fscanf("%d", &num)) {
fclose(fag);
fputs("OP is still a faggot\n", stderr);
return -2;
}
printf("Number = %d\n", num);
fclose(fag);
return 0;
}

fuck
fscanf(fag, ...)

user, you're supposed to be rude to OP. He should grab a book and learn it himself and you enforce his bad behavior by giving him the solution.
Say, that you won't do it again!