#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    101
    Rep Power
    0

    I don't have enough memory?


    Code:
    #include<stdio.h>
    #include<errno.h>
    #include<process.h>
    
    int main()
    {
    	int memory = execl("C:\\Users\\mineJons\\Documents\\Bckground.html","C:\\Users\\mineJons\\Documents\\Bckground.html",NULL);
    	printf("%d %d",memory,errno);
    	getchar();
    	return 0;
    }
    When printed, I get -1 and 8

    I look up online to see what the error number 8 is and it says:
    "Not enough core (for example, not enough memory to execute the exec() function)."

    Why can I open up programs through my C:\\program files(x86) directory but can't open any files through the ones I'm trying now? I can't evaluate how it doesn't have enough memory to execute the functions. Thanks for the help
  2. #2
  3. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,114
    Rep Power
    1803
    You would find it a lot easier to use perror() to interpret errno correctly.
  4. #3
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,395
    Rep Power
    1871
    > int memory = execl("C:\\Users\\mineJons\\Documents\\Bckground.html",
    Why do you think "executing" an HTML file is going to work?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,641
    Rep Power
    4247
    Since you are running on windows, you could use ShellExecute() to fire up the HTML file in a browser. For one thing, ShellExecute will use the default registered app (IE, Chrome, Firefox etc.) on the given machine to open the HTML page.

    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx for documentation.
    E.g:
    Code:
    ShellExecute(NULL, "open", "C:\\path\\to\\file.html", NULL, NULL, SW_SHOW);
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    101
    Rep Power
    0
    "Why do you think "executing" an HTML file is going to work?"

    My first examples were text files in the same directory. I just ended up with that .html file.

    As for using ShellExecute(), it worked! Thanks. But for curiosity, can someone tell me why I had too much memory when using execl? And can I fix it using execl?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    101
    Rep Power
    0
    Here's the code (with the .txt file extenstion instead of .html)

    Code:
    #include<stdio.h>
    #include<errno.h>
    #include<stdlib.h>
    #include<process.h>
    
    int main()
    {
    	char *x;
    	int memory = execl("C:\\Users\\mineJons\\Documents\\ada.txt","C:\\Users\\mineJons\\Documents\\ada.txt",NULL);
    	printf("%d %d\n",memory,errno);
    	itoa(errno,x,10);
    	perror(x);
    	getchar();
    	return 0;
    }
    Same error. Can I not open these kinds of files?
  12. #7
  13. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Alpharetta, GA
    Posts
    1,806
    Rep Power
    1570
    Not with execl(), no. The exec*() functions are all for loading executable files - which in Windows means .EXE files almost exclusively - into the current process space and transferring control to the executable code. It is a port of a low-level process management function that only works for true executable binaries.

    The reason ShellExecute() works is because it actually invokes explorer.exe and passes the file name to it. Since the Windows Explorer shell is aware of the various extension bindings, it recognizes the file type, and invokes the appropriate program.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

IMN logo majestic logo threadwatch logo seochat tools logo