|
Hey every one...
How to Declare a program, Menu or a dialog
I mean if we have Word for example... How we can Declare the main window... and after that i want to Declare a menu or a dialog inside the Word....
so how to do that?
thanks
|
|
|
|
|
You are having troubles with pass-by-value semantics. Consider the following:
void foo(int var)
{
var=1;
}
...
int x=0;
foo(x);
The value of x after calling foo(x) will still be 0, as you're passing a copy of x to foo (i.e. its value) and not the real variable. C++ has so called references to allow you to pass a variable rather than a value:
void foo(int& var)
{
var=1;
}
...
int x=0;
foo(x);
The only difference is the & in the declaration of foo . Use the same technique in your code. If this is your first exposure to references, I suggest you learn more about them in some C++ book or online reference. Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
To add to the previous poster's comments:
You are passing the copy of a pointer to pointer to int (int **). So when you are allocating space and saving the address, you're saving this address in a copy of the variable a, which has nothing to do with your a.
To solve this you need to either return the newly created array from your function by rewriting it as
int ** CreateArray(int i, int j)
Or you need to pass pointer to pointer to pointer to int (int ***) and set the value like this:
<br />
<br />
void CreateArray(int ***array,const int i,const int j)<br />
{<br />
*array = calloc (i, sizeof(int *));
loop<br />
*array[i] = calloc(...);
end loop<br />
}<br />
In your place I'd return the value instead of using int ***.
|
|
|
|
|
Yeah I suspected that and changed the function to take int *** .
But i have another function
void PrintArray(int **array,const int i, const int j)
{
int k=0,m;
for(;k
|
|
|
|
|
void CreateArray(int **array,const int i,const int j);
void main()
{
int **a=0;
CreateArray(a,3,3);
}
// creates a 2d array
void CreateArray(int **array,const int i,const int j)
{
int t=0;
if(i>0 && j>0){
array = calloc(i,sizeof(int *));
if(array){
for(t=0;t
|
|
|
|
|
I use Microsoft Visual Studio .NET 2003 and creating an unmanaged program. I included iostream but its functions (like cout and cin ) still won't work. Help me!
P.S.: I want an UNMANAGED (not-.NET) program.
|
|
|
|
|
Without further info it is hard to tell what kind of problem you've run into. Even so, I might risk the following: are you using cout or std::cout (same for cin )? It is the latter that you should be using.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
By using the std namespace you make the program managed (at least I think so). I need a pure C++ program, without any .NET elements.
|
|
|
|
|
By using the std namespace you make the program managed (at least I think so).
No no, the std namespace has nothing to do with managed/unmanaged code. You can use it. Believe me
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Thanks.
|
|
|
|
|
Hi
I have Visual C++ 6.0
I want to move the left side of Horz ScrollBar some pixels to the right in an MDIChild window in an application with split bar with two rows and one column.
How can I accomplish this ?
Thanks
Manosza.
|
|
|
|
|
hello,
i was wondering which set of functions to use to store user preferences in the registry. is there an example on the web of how best to do this?
thanks,
edward herskovits
Edward H Herskovits
Noetic Systems Incorporated
www.noeticsystems.com
"When certainty is not enough."
|
|
|
|
|
If you're using MFC, I think the best ones to use are the methods of your CWinApp class, like WriteProfileString() ,WriteProfileInt() , and WriteProfileBinary() . And use the respective Get***() functions to get the info back from the registry.
while(true)
{
TryToLearn("C++,MFC");
}
My articles[^]
www.stillwaterexpress.com
bdiamond
|
|
|
|
|
ehh wrote:
is there an example on the web of how best to do this?
How about here?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Even if you get your hands on a registry access class (and there are several on this website), keep this in mind:
1. If you want the setting ot be a PROGRMA WIDE setting, then youc an place it into HKEY_LOCAL_MAHCINE, but most users will onyl have READ access to the values.
2. If you want it to be a per-user setting, then you can read and write to the HKEY_CURRENT_USER
3. If you want new users to inherit some default settings, then user HKEY_USERS\.Default as the base key to write the information.
|
|
|
|
|
Thanks to all who responded; I have a much better idea of how to implement user preferences now.
Thanks!
Edward H Herskovits
Noetic Systems Incorporated
www.noeticsystems.com
"When certainty is not enough."
|
|
|
|
|
could someone help me code this. I've tried everyway i know how.
1. You will simulate a memory bank of a computer using an array.
1. The program will read in an input file that represents a series of commands to the system to start and stop of different programs.
2. Each program will have an identification number (int) and a memory size (int)
3. Your program will search the array representing the computer's memory for the smallest available space in memory large enough for the program being called and reserve those array locations for the program being started.
4. When an end program call is made the program's memory is released.
5. If enough memory is not currently available, the program will go on a waiting list until such time as enough memory is available in one location or until it is cancelled.
6. The waiting list gives higher priority to programs started first.
7. Your memory array will be of a fixed size of 2048 units.
8. For the purposes of this lab the waiting list can be implemented as an array of length 50.
9. Output each action taken to the screen (program starting, stopping, entering or leaving the waiting list).
|
|
|
|
|
Izaquad wrote:
I've tried everyway i know how.
And those ways would be how?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
//void MemLocation(int beginEnd[][3]);
int main()
{
// declaring variables.
int memArray[2048] = {0};
string action;
int progID, memSize, memBegin, memEnd = -1;
int waitArray[50] = {0};
string fileName;
int arrVal =0;
// prompting user to enter file name for input
cout << "Please enter name of file to read." <<endl;
cin="">> fileName;
// declaring and opeing input
ifstream inFile ("lab8data.txt");//fileName.c_str());
cout << endl;
while (!inFile)
{
inFile.clear();
cout << "File, " << fileName << ", not found! Please re-enter." << endl;
cin >> fileName;
inFile.open (fileName.c_str());
}
while(!inFile.eof())
{
inFile >> action;
if(action == "Start")
{
if(arrVal < 2048)
{
inFile >> progID >> memSize;
cout << "Starting program: " << progID << endl;
arrVal += 1;
}
else
{
inFile >>progID;
cout << "Program "<< progID << " is entering waiting list."<
|
|
|
|
|
Ok, so what works? What doesn't work? Have you stepped through the code line-by-line? What does the lab8data.txt file look like?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Start 1 1000
Start 2 500
Stop 2
Start 3 1200
Start 4 2000
Stop 1
Start 5 750
Start 6 200
Stop 5
Stop 3
Stop 6
Stop 4
Start 7 100
Start 8 500
Start 9 50
Start 10 1500
Start 11 450
Start 12 500
Start 13 100
Start 14 500
Stop 14
Stop 7
Stop 10
Stop 11
Stop 9
Stop 8
Stop 13
Stop 12
|
|
|
|
|
i suggest you pay to some one to help you complete the long school project.
includeh10
|
|
|
|
|
Whatever you're doing:
1. Find a good/free/available debugger and learn how to use it. You'll save time. As David Crow suggested step through what you have and see if it works. What values the variables have etc.
2. Plan your program. I remember my projects, and I'd write them off the top of my head. You'll do much better to lay out and draw some stuff. For example you know you'll need a parser for the file. That's one block. You'll need something to manage your queue (add/remove items from it). That's another block. You'll need a way to keep track of what range of memory is taken and what isn't.
|
|
|
|
|
Hello there!
I figured this site would be a perfect place to ask about my problem (I came here because I was searching for a solutiong on Google).
Anyways, here's my problem. I use Visual Studio NET 2003 to write C/C++ projects. The nature of my assignments requires me to limit the length of the code lines by 80 character, because the code is printed out often and this is how our printers are set up. In other editors that I used before, there was a way to display the vertical dashed line so many characters away from the left margin, or to physically limit the width of the edit page. In VC NET however, I couldn't find any such option, and thus it gets on my nerves constantly having to pay attention to the length of each line of code that I write
It would be amazing if I found a way to limit the Edit Window width (kind of like in MS Word) rather than having it stretched to the right infinitely. There's a selection margin on the left side of the Edit Window (where the line numbers are), would be great if a similar margin was on the right hand side too, with the actual text area in between being 80 character wide.
I don't know much about windows api, I work on unrelated projects, but I'm sure that it would take a few minutes to code this for someone who knows what he's doing.
I would greatly appreciate if someone wrote this add-in for me (or pointed me to an existing one).
|
|
|
|
|
I think the best way to go about this (and easiest) would be to write a VBScript macro in your macrose IDE. I don't know very much about the syntax, but I've written a few of my own macros by looking at existing ones (the samples that come with VS). I would write the macro so that it loops through each line, and if it's longer than 80 characters, reversefind the first space and issue a linebreak and maybe a tab character or something like that that would let you know that it was continued from the previous line, or maybe something like /*cont...*/ on the following line before the actual text.
while(true)
{
TryToLearn("C++,MFC");
}
My articles[^]
www.stillwaterexpress.com
bdiamond
|
|
|
|