Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
We need to write a C/C++ code that will check whether the memory allocated to the program at the initial and the memory returned to the system is the same or not.
My idea is to find the memory usage at beginning and at ending and subtract.
But how to find the memory usage?
Any other idea please.
If you are using the Linux/Unix based OS , you can involve the top utility ans see the difference.no need to reinvent the wheel.
use this in your c code :
uint find_memory_usage()
{
sprintf(cmd, "/bin/top");
system(cmd);
}
You can use exec family functions or system call as well for this.
This link on SO may also help.
or this one.
I think this code will help you to find size of your c code:
#include<stdio.h>
#include<bios.h>
int main(void)
{
printf("memory size %d kbite\n", biosmemory());
return 0;
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Develop an algorithm that can be used to determine whether a Stack object S has exactly one element.
I am not a programmer, I choose this course as an elective to see if I would be interested. I don't know where to begin with this question.
You most likely want to check the documentation of C++ on stacks. This took no time to find:
http://www.cplusplus.com/reference/stack/stack/size/
Your function has to return stack.size() == 1. If the question is asking to develop an algorithm based on the size in memory the stack size allocates then it's slightly more involved.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
In turbo c 3.2 I am getting
Divide error
and in code blocks IDE I getting error that
initgraph() and closegraph() are refrence at compile time. (I added graphics header and library file in folder of codeblocks).Please give me solution?
the code i written is
#include<graphics.h>
int main()
{
int a=10,ab;
initgraph(&a,&ab,"C:\\TURBOC3\\BGI");
circle(100,200,20);
closegraph();
return 0;
}
In addition to the backslash issue in the path, it's extremely unlikely that you are using a 3270 compatible display. Why don't you pass in the address of a with a=0. ab must be set to a requested mode unless you set the driver to autodetect, which will then select the highest available mode. See here.
The path string should be "C:\\TURBOC3\\BGI" (note the double backslashes instead of single backslashes)
I hope this solves the problem. I can't see any other error in code.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I would like to run a what I called "script C code" from string in my C++ program, for exemple :
int main(){
// my string (from a file): printf("Hello, Stackoverflow!")
RunScript(MyStringScript);
return 0;
}
I could use clang or other, but I have no idea how to do that...
PS: The goal is not to make a C interpreter, no, just run a C code to broaden my program.
The best way for reaching your goal, is to use a C interpreter library.
For example you can use this one: https://github.com/jpoirier/picoc
You could also do it with libjit. Because you are then running the system compiler, any ISO C/C++ code can be compiled (picoc is not fully ISO C complete)
Obligatory disclaimer: Running user supplied code at runtime is very dangerous unless it is properly sandboxed. Maybe consider doing it another way.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm fairly new to c++ and was wondering if there is a way to figure out the canvas' size of another program?
For example, code something that will tell me the size and position of a program like Task Manager or CommandPropmt. Of course, they would have to be opened first.
It's quite easy to do this - get the window handle with FindWindow(), and then get the size of the window using GetWindowRect() or GetClientRect(), depending on which bit of the application window you want the size of. All these functions are part of the Win32 API and are fully documented online.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
one of the most part in programming is debug problem and increase performance ( i think! ), and I never did serious debug because I just write small programs.
but this time i write a program that little big, and i doubt there is some problems in memory.
so I want a debugger that do the following:
support c++ .
check if there is leak memory .
calculate the size of memory that my application allocate .
check every function or object separately .
using GUI ( graphical user interface ) .
If you're using Linux try using Valgrind. It does everything you specified.
Check out valgrind and gdb. With those two tools you should be able to do what you want. Having said that they're not GUI's, but that's not a downside.
Microsoft's run time libraries have lots of useful functions to track memory. Only works on Windows though.
On Windows you should check out WinDbg.