### Thread: I don't have enough memory?

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. You would find it a lot easier to use perror() to interpret errno correctly.
3. > int memory = execl("C:\\Users\\mineJons\\Documents\\Bckground.html",
Why do you think "executing" an HTML file is going to work?
4. 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);
5. 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?
6. 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;
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?
7. 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.