Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7674331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:42:52+00:00 2026-05-31T16:42:52+00:00

I’m working on a program that takes in a Wavefront .obj file and eventually

  • 0

I’m working on a program that takes in a Wavefront .obj file and eventually places it into OpenGL and displays the object.

Right now I’m just trying to read in a simple cube.obj file and print the contents. Its content is:

v -1.0 -1.0 -2.0 
v 1.0 -1.0 -2.0 
v 1.0 1.0 -2.0 
v -1.0 1.0 -2.0 
v -1.0 -1.0 -4.0 
v 1.0 -1.0 -4.0 
v 1.0 1.0 -4.0 
v -1.0 1.0 -4.0 
f 1 2 3 
f 3 4 1 
f 6 5 7 
f 5 8 7 
f 2 6 3 
f 7 3 6 
f 1 4 5 
f 4 8 5 
f 4 7 8 
f 4 3 7 
f 5 6 1 
f 6 2 1

I placed the cube.obj in the command-line args and did a check to see if it opened.

FILE *fp;
fp = fopen(argv[1], "r");
if(fp == NULL)
    fprintf(stderr, "cat: can't open %s\n", argv[1]);
else
    printf("works");

cin.get();

It’s not even opening. Is there a better way to open the .obj file (as well as eventually print the contents of it?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:42:53+00:00Added an answer on May 31, 2026 at 4:42 pm

    You have not provided enough information here, but it seems obvious that the problem is very likely the contents of argv[1]. What does the pointer at argv[1] point to? Don’t assume, use your debugger and look at it. I bet it’s not what you think.

    You also don’t consider the fact that your program may not have been launched with any arguments, meaning that argv[1] is reading past the end of a buffer. This is tangential though.

    EDIT:

    Per your comment, you need to provide the full path of the file to fopen. It should work if the file is in your running directory, but depending on your environemnt (VS is one) that may not be as simple as it sounds.

    I ran a test with a file foo.txt in my \project\debug directory, the same directory as my executable. It failed to open the file with a relative path, but succeeded with the full path.

    However, if I simply double clicked the executable in that directory it worked. Apparently VS is doing something behind the scenes that is changing the working directory.

    To use relative paths, right click the project -> Properties -> Debugging -> Working directory. Set that to your output folder and you should be fine.

    #include <stdlib.h>
    #include <stdio.h>
    #include <Windows.h>
    
    int main() {
        FILE *file;
        if(!(file = fopen("foo.txt", "r"))) {
            printf("no worky");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.