[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 244 KB, 1280x634, Pressure_frontpage.jpg [View same] [iqdb] [saucenao] [google]
4109865 No.4109865 [Reply] [Original]

why is fopen such a fag?

here's some code (this is being built in visual studio 2008)

FILE *inf;

tbInit(GLUT_MIDDLE_BUTTON);

inf = fopen("patch.dat", "r");
if(inf==NULL) {
printf("Error in attempting to open patch.dat file!\n");
exit(0);
}

i'm attempting to open that patch.dat file as part of a little OpenGL program. patch.dat just holds about 42 long values with spaces, no line break, nothing fancy.

for whatever reason, my program ABSOLUTELY REFUSES to open patch.dat, or even see it at all. no matter what i do, inf stays NULL. i'd put patch.dat right next to the actual .cpp in its original folder, i've put it in the visual studio 2008 projects folder, on the root of my C drive, on my dekstop, everywhere
fopen simply NEVER sees it

what the hell?

>> No.4109879

It has to go in the current working directory of the program, which if you're just clicking on the executable or running it from your IDE is probably in the same directory as the executable.

There's some sort of call you can make, though, to explicitly indicate the working directory.

>> No.4109895

Probably an issue with your IDE. This is why people should learn to code command line before they even touch an IDE.

>> No.4109916

>>4109895
THIS. gcc and make. Learn them.

>> No.4109928
File: 41 KB, 600x458, but it's wrong.jpg [View same] [iqdb] [saucenao] [google]
4109928

>>4109895
This isn't an IDE issue, it's a moron-who-doesn't-understand-directory-trees issue.

>>4109916
>2011
>recommending a command-line compiler over an IDE

Just die.

>> No.4109938

>>4109879
That's what I thought as well, but putting in an explicit access like c:/blah blah/patch.Eatery doesn't work either.
I also put it in the directory of the executable, nodice

>> No.4109940

>>4109928
If you want to grab your build process by the balls and make it do exactly what you want to do, then Makefiles/GCC are the way to go.

But if you'd rather put your build process in the hands of a more knowledgable source, then IDEs all the way.

Understanding directory trees wouldn't be a problem if he was explicitly running his program from the command line. When you run it from an IDE, the CWD could be anywhere.

>> No.4109943

>>4109938

.dat auto corrects to Eatery now?

>> No.4109951
File: 20 KB, 262x345, nigga please.jpg [View same] [iqdb] [saucenao] [google]
4109951

>>4109940
>If you want to grab your build process by the balls and make it do exactly what you want to do, then Makefiles/GCC are the way to go.

...and if you want to actually design a program that does something useful, instead of dicking around with pointless crap that the end user couldn't give less of a fuck about, then VS is the way to go.

>> No.4109961

>>4109951
The entire GNU/Linux project uses Autotools, but I guess nobody gives a fuck about GNU/Linux...

>> No.4109963

>>4109938
Call GetLastError() and see why it failed

>> No.4109969

>>4109961
No we really don't, but sometimes it's cool that it's there.

>> No.4109974
File: 1.18 MB, 266x199, i_really_dunno.gif [View same] [iqdb] [saucenao] [google]
4109974

>>4109969
>mfw 4chan runs on LAMP

>> No.4109979

>>4109961
>but I guess nobody gives a fuck about GNU/Linux...

I know I don't.

>> No.4109992

C should burn. :P

>> No.4110002

>>4109979
>>4109969
The well-being of the entire internet depends on the GNU/Linux project.

One guy working on OpenSSL accidentally forgot to uncomment a line of key generating code and the entire Internet flipped out because SSL security was at risk.

On second thought, though, it's a good thing that anti-C and anti-CLI people like yourselves would stay away from the open source community.

>> No.4110006
File: 12 KB, 250x250, that's nice.jpg [View same] [iqdb] [saucenao] [google]
4110006

>>4110002

>> No.4110007
File: 555 KB, 732x720, 1320890187286.png [View same] [iqdb] [saucenao] [google]
4110007

>>4109974
>the man on your pic is a scientist
>my face then

>> No.4110026

>>4110002
Sorry if I don't give thanks for every fucking thing responsible for making up life as we know it.

>> No.4110034
File: 60 KB, 480x360, what the h.jpg [View same] [iqdb] [saucenao] [google]
4110034

Wait, what? There are actually still people out there writing code in fucking Notepad and compiling it with a command line utility?

Are they stuck in the past like the people who still listen to vinyl records, or is Unix/Mac/whatever the fuck they're using actually so ass-backwards that no decent IDE has ever been written for it?

How the hell does anyone write anything without, for example, Intellisense?

>> No.4110054

>>4109963
>GetLastError()
i'm going to attempt this now

>> No.4110055

>>4110026
Apache, an open source HTTP server, runs on over half of the web servers.

Apache is written in C and compiles using GCC and a series of Makefiles. It was written by tons of programmers working over the Internet together, and I can guarantee with near-absolute certainly that the most complicated "IDE" any of them ever bothered to use was emacs.

GCC/Makefiles aren't just some archaic tool, they're the foundation of modern coding/hacking as we know it.

COME ON LINUX PEOPLE, BACK ME UP!

>>4110034
No, writing code in emacs or vi and compiling it with gcc and make.

emacs/bash is the only IDE I will ever need

I am willing to bet that none of you have ever worked on an *nix machine.

>> No.4110061

>>4110034
>Notepad

no one ever did this except for people who had no clue how to work the computer

Emacs,Vi,Vim, they've been here for a long time

>Unix/Mac
>living in the pass
Using your logic every actual functioning big company in this world, School, University lives in the pass. Lets not forget all the people running linux to host their http servers, ftps,etc.

>how the hell does anyone write anything without Intellisense
You're incapable of remembering things and thus need something to auto complete code for you which you probably have not a clue how it works since you haven't even taken the time to know its full name .


You sir are a moron,
Good day sir.

>> No.4110068

>>4110061
THANK GOD! I knew I wasn't alone!

>> No.4110074

>>4110061
>You sir are a moron.
>Duh hurr durr in da pass. In da pass. Gah derp hurrrr.

>> No.4110076

>>4110074
If you look pass the spelling errors, you'll find his point to be very valid.

>> No.4110079

>>4110074
When in doubt, strawman.

Fun Fact: 4chan server is living in the pass, god when will they upgrade to windows....

>> No.4110096

>>4110055
>I am willing to bet that none of you have ever worked on an *nix machine.

IIRC they made us use Unix in Intro to C.

Pain. In. The. Ass.

>>4110061
>You're incapable of remembering things and thus need something to auto complete code for you which you probably have not a clue how it works since you haven't even taken the time to know its full name .

Or, alternatively, I'm not a big enough neckbeard to have memorized every member and method of every standard class (or even every member of my own classes), exactly how it's spelled/capitalized, and exactly what the parameters are, and have other shit to do with my time besides looking it up every damn time

Or maybe I like being able to change a variable name and have my editor automatically fix every place I use it instead of wasting ten minutes doing searches

>> No.4110105

>>4110096
Knowing how to use documentation is an important programming skill, and developing a familiarity with an API will greatly improve programming speed.

IntelliSense hinders the development of both these things.

>> No.4110112

>>4110105
not really, documentation isn't anything magical, and intellisense just removes the pointless memorization
also, familiarity with the API isn't hindered, since you spend more time using functions and less time looking them up because you forgot the S is capitalized

>> No.4110116

>>4110105
You're just an idiot.

If you want to deliberately make things more difficult for yourself than they need to be, fine. When you feel like joining the rest of us here in the 21st century, let me know.

>> No.4110122

>>4110096
>or even my own classes

If you can't remember your own class definitions and members then you're a poor programmers. You probably wrote them shitty and they are probably inefficient. I bet you also use the std wrong, you write shitty code because you don't know proper methods and you have not a clue whatmost of the std even says


>>4110112
>less time looking them up
That's the thing, you don't have to look them up because you would have already known them. If you know your std then you know their style of writing and how they operate

>> No.4110126
File: 9 KB, 275x183, imgres..jpg [View same] [iqdb] [saucenao] [google]
4110126

>>4110112
If you spend less time relying on software to write your code for you, then you will be better equipped to write software.

I only rarely need to Google for OpenGL documentation now because I've used the API so much. I write GL code a lot quicker now, because I immediately know the name of the function I'm looking for.

I'm not making programming harder on myself, I'm making it easier at the expense of practice.

>mfw all the Linux hacking jobs will be mine

>> No.4110131

>>4110122
>If you can't remember your own class definitions and members then you're a poor programmers.

When you get past C++ 101 and start using classes with dozens or hundreds of members months after you originally wrote them, you'll have trouble remembering too.

>That's the thing, you don't have to look them up because you would have already known them. If you know your std then you know their style of writing and how they operate

And if we made every child memorize the dictionary, there'd be no more spelling errors in the world.

It's a waste of time. Feel free to unnecessarily handicap yourself if you like, though. Less competition for the rest of us.

>> No.4110143

>>4110131
>You'll have trouble remembering
A sign of poorly written code.

>It's a waste of time
Reading the standard is a waste of time? Coding the proper way is a waste of time you say? You think your C++ 101 taught you everything there's to know and in a proper manner? Please go back to doing what you were doing before this thread, right your shitty improper programs, contribute the the community and help degenerate it with more shit that is broken and full of bugs.

>> No.4110146

>>4110126
So making it harder to learn something makes you better at it? Huh?

By that logic, we should forbid children from using the internet and make them crawl to the library on their face to gather information for class.

>> No.4110153

>>4110146
Your analogy is not what the point of his post was about and i bet that kid that went to the library turned out to know more than the kid that sat behind a computer on the internet

>> No.4110156
File: 31 KB, 469x428, 1322429792801.jpg [View same] [iqdb] [saucenao] [google]
4110156

>>4110143
Haha ok, whatever dude.

>> No.4110161

>>4110054
OP here, running into some trouble
GetLastError() doesn't seem to have much, if any, official documentation, does it belong to any specific libraries i must include?

>> No.4110163

>>4110153
so, you're not trolling, you're just an idiot?

>> No.4110165

Allow me to restate: **LINUX** (and 99% of the software available for GNU/Linux sytems) was written with the makefile/GCC method.

If you don't understand the significance of that, then I am done talking to you.>>4110161

>> No.4110166

>>4110156
Yes, yes you're a troll.... thinking that reading the whole standard is a waste of time...


next i'm going to be hearing about how you think you can beat compiler optimizations with operations it already optimizes for you

>> No.4110170

>>4110161
give perror in stdio.h a look

>> No.4110181
File: 21 KB, 280x287, Damn-kids-GET-OFF-MY-LAWN.jpg [View same] [iqdb] [saucenao] [google]
4110181

Surprised no one ITT has come out in favor of programming with punch cards.

After all, relying on compiler warnings or run-time errors to tell you where you went wrong just develops bad habits. You learn to be a better programmer when you have to get it right the first time.

Right?

>> No.4110185

>>4110161
http://www.cplusplus.com/reference/clibrary/cstdio/perror/

It even gives you exactly the same situation you're in and how you deal with it. I suggest you take the time to read about the things you're trying to do before you jump head first in with no clue and then complain on 4chan

>> No.4110186

>>4110181
What are you talking about? Convection currents created by butterfly wings to directly modify the magnetic data on the hard drive is the way to go.

No but seriously, C and 90's style hacking is far from dead.

>> No.4110191

>>4110161

Just for experiment sake, put the file in the root directory and try opening it from there.

fopen("c:\\whatever.dat", "r")

If that doesn't work, then something really is screwy.

>> No.4110199

>>4110181
When in doubt, Strawman.

And seeing how you think that logic makes any sense i doubt you were even close to being alive when punch cards were in use for programming seeing how you clearly don't know how much it helped to go all digital and how the process of punch card programming worked

>> No.4110200

>>4110185
Fuck off back to one of the endless, useless linux forums if you want to bitch at noobs and whine about how much better coding tools were in the fucking 70s.

>> No.4110205

>>4110200
>give the OP the exact reference he needs to solve his error problem
>some random faggot that has not a single clue what he's doing tells me to fuck off


/sci/ sure is shitty tonight

>> No.4110207

>>4110191
well shit! that seems to have solved it for some reason

i'm going to put that perror line in there though, to figure out WHY every other method was not working. fucking bizarre

>> No.4110209

>>4110199
Seeing how you actually seem to be familiar with the punchcard system, my guess that you're a 60+ year old (near)retiree who just instinctively fears anything new seems to have been roughly correct.

>> No.4110214

>>4110209
Dude, cut it out with the ad hominem

My guess is that you're a highschoolfag who learned C++ on the Internet and wants to go into game design.

>> No.4110220

>>4110209
>fears anything new

but i gladly converted to the digital programming age because i saw it's benefits to the old system.


I'm going to sleep now, so enjoy thinking you right

>> No.4110221

>>4110207
I think maybe it doesn't like when you use "/" in file paths. I always use "\\", so I don't remember.

I'm sure the neckbeard who's spent his entire life memorizing reference books could tell us, though. Or, alternatively, a 3 second google search.

>> No.4110225

>>4110214
>>4110220
i personally respect the old guard
they know how to work on systems with low resources

>> No.4110234

>>4110221
Knowing how to use Google is an important programming skill. I would trust my googling skills over IntelliSense any day.

>> No.4110240

>>4110221
well, the reason i was looking at "/" is because
1) every fopen i've ever used stuck with that, i've never seen \\ used
2) my professor actually recommended that

>> No.4110245

>>4110240
C is typically used for Unix-like systems, so that's why you see them all with the forward slashes.

If you're programming C on Windows, use backslash-escaped backslashes (i.e. "\\") which is how Windows divides up paths.

>> No.4110259

>>4110245
this explains a great deal, as my professor was using visual studio on her Mac, and i'm on windows
i suspected the problem was arising from that divide

>> No.4110262

>>4110259
Python's really cool because you just use os.join and it takes care of determining which slash you need to use.

But that's beside the point :)

>> No.4110281

>>4110262
oops, os.path.join