A fair portion of the population have yet to figure out what 'R' means, never mind the rest of it.
I suspect many barly know how to turn on the computer too, let alone what google is :icon_eek:
A fair portion of the population have yet to figure out what 'R' means, never mind the rest of it.
I suspect many barly know how to turn on the computer too, let alone what google is :icon_eek:
You still get the auto-send message, even if you report your own self.
Hitting the submit button a couple times, in the lag, isn't something to cry over.
Yes you will get an auto-send message about the mod deleting the thread, but you probably won't get the warning, unless the mod specifically issues one.
If you have a static array, such as struct students std[200];
then to delete on of the students you a couple choides
1) just reset the ID and other variables to some default value (such as 0). Then when searching just bypass any arrays whose id value is 0.
2) Move all the structures up one slot to fill up the structure you want deleted. For instance if there are 10 structures in the array and you want to delete #5, then move 6-10 up one to 5-9 and set the 10th one to default values, such as 0 or "" string.
If you use a vector instead of the above all you have to do is call the vector's erase() method.
two problems:
1) You have to prototype that function -- meaning you have to declare it before using it. Add this somewhere above function main() char *long2hex(long c)
2) line 11 is incorrect: it should be this: b[0]=long2hex(a);
But why did you declar b as an arry of 5 character pointers when all you needed is one?
okay tnx but pls how can i create an array that can sort?
The array you created can be sorted. There are more efficient ways to do it, but what you did is ok. Google for "bubble sort" to get the algorithm for that one, which is the easiest to code.
And, as previously mentioned, you will have to change that structure, because it needs to contain strings for name, geneder and nationality. What you have will only hold a single character
struct student
{
int ID;
std::string name;
std::string nationality;
std::string gender;
};
If you are required to use character arrays instead of std::string you could do it like this too:
struct student
{
int ID;
char name[80];
char nationality[80];
char gender[2]; // either 'M' or 'F'
};
what you need to do is write a switch statement in main() that will process each of the menu options. For example if the user selects option #1 you do not want to make him also do the other options.
After that last cout in main() you need to add something like the following
int answer;
cin >> answer;
switch(answer)
{
case 1: // insert new record
InsertNewRecord(array); // you will have to add this function
break;
// now do this for each of the other options
}
Those are the requirements, not a question. Are you asking us to write the program for you?
what is your question?
If your trying to read the c++ manual then where is the c++ manual or is cplusplus.com it.
There really is no one physical manual any more, to RTFM is sort of an archaic term. 20 years ago Microsoft used to ship all the manuals with their compiler. But they stopped doing that when the internet became so popular, which probably saved them millions of dollars in publishing costs.
You can find info about c++ everywhere -- on the net by searching for the function you want, such as if you are looking for ifstream just google for "std::ifstream". Or you can find lots of books at www.amazon.com. Or you can buy a copy of the c++ iso standards
int main()
{
short *ay = (short int*)malloc(sizeof(short int)*66000);
printf("%p\n", ay);
return 0;
} //end of main function
The above worked without a problem using VC++ 2008 Express. Chalk another one up for Microsoft vc GNU :) (so far that makes two during the past seven days)
which line of that code are you talking about?
As far as I can tell farmalloc() is only implemented on 16-bit compilers. There is no such thing as a "far heap" in 32 (or more)-bit programs because they use the flat memory model where all memory is considered near.
i am now working on another way to load in the data by tokenizing the data of each object (e.g. name, id, etc) into/from a plain text file...would that be a better way than to write in the whole object into the file?
thanks alot for your explaining :P
yes, I agree that would be an excellent idea. Binary files just don't work very well with c++ classes.
help you fix what??? The most obvious problem is that it is using uninitialized variables a, b and c. Next, function average only takes one argument, not 3. Either change that function to accept three arguments or only pass one.
[edit]^^^ what Tom said. [/edit]
just change the filename. Otherwise how to do that will depend on the compiler. Some compilers have option flags to do that and others don't.
That line could have been coded more simply like this: writer.write(reinterpret_cast<char*>(this->myAdvisor)
If you just write out the this pointer all that will get written is the value of the myAdvisor pointer, not the object to which it points.
Depending on how the rest of your program is written you may not have to write out myAdvisor at all.
When you read myAdvisor back you will first have to allocate memory for myAdvisor and then read into that pointer. I don't know how you set the value of that pointer initially, but you will have to do it again before reading back from the data file.
>>writer.write(reinterpret_cast<char*>(this)
The class can not be written that simply because it contains std::string and pointers. That makes the serialization algorithms much more complex and makes the file a variable length records, almost like any ordinary text file.
If you have to use binary format, I would suggest you use character arrays for Human class name and id to simplify the file and make it use fixed-length records.
class Human {
protected:
char name[80], id[80];
public:
Human(string n = "", string id = "") {
changeName(n);
changeID(id);
}
string getName() { return name; }
string getId() { return id; }
void changeName(string n) { strcpy(name,n.c_str()); }
void changeId(string id) { strcpy(this->id,id.c_str()); }
void showData() {
cout << "Name: " << name << endl;
cout << "ID: " << id << endl;
}
};
All it needs to write out is the base class since the derived classes have no objects of their own that need to be serialized. writer.write(reinterpret_cast<char*>(&*this->myAdvisor)
Post code.
A double click is nothing more than two clicks in rapid succession. Your program will get two click events, not one.
[edit]Never say never! If you are using Windows hooks then you might want to read this article, especially one of the comments at the end of the article.
open the file, seek to end, get position, then finally check if position is 0.
ifstream in("myfile.txt");
in.seekp(0, ios::end);
int spot = in.tellg();
if( spot == 0)
{
cout << "Empty file\n";
}
Easy implementation. It becomes a little more complicated when you want to also use '*'. Much more complex implementations can be found in boost regex library (regular expression library).
bool wordPattern(string pattern, string word) {
if( pattern.length() != word.length())
return false;
for(int i = 0; i < word.size(); i++)
{
if( pattern[i] != '?' && pattern[i] != word[i] )
return false;
}
return true;
}
Forget about 2005 Express -- its been updated to 2008 Express. 2008 is a better compiler anyway and doesn't need the Windows SDK in order to produce windows gui programs. But you have to hurry because it won't be available for much longer, as soon as 2010 is released (its already in beta).
>>if(_stricmp(value,gen_arr)== 0){
gen_arr a single character array? or is it an array of strings? If its a single character array then do this (without indexing) if(_stricmp(value,gen_arr])== 0){
1) yes, but beware of stack overflow if the array is too large.
2) probably, but some operating systems may not deallocate it.
3) I don't know.
it would have been even easier had you used inline code
namespace Test
{
class a
{
public:
void afunction () {cout << "this workd\n";}
};
you have not written the implementation code for the functions in those two classes.
4. String formatting using <iomanip.h> header file
OMG :icon_eek: You mean to tell us that you school is teaching you the wrong stuff!
iomanip.h has been deprecated (obsolete) for almove 10 years now. The current file name is <iomanip> (no .h extension). I wonder what else they have been trying to teach you that is either just wrong or long obsolete???
Don't sit there expecting anyone to do your homework for you because that will teach you nothing. Code each of those 6 requirements one at a time and you will have the assignment done before you know it.
ls, pwd, and who are *nix commands while graphics.h is a MS-DOS heder file using TurboC compiler. The two can not be mixed.
You need to clarify exactly what it is that you want. If you can not, then you probably need to study C language more until it becomes clear in your head. Wold you attempt to build your own airplain if you don't know the first thing about it? Of course not. The same for programming.
The 'C' just means C-language.
>>Is that a common practice in software development?
No. Microsoft coders like to use such prefixes in their classes/structures, but not in filenames.
What exactly is an "interactive menu"? One that talks back to you? And "interacts with you" ? A menu that shocks the keyboard if you do something wrong?
Welcome to DaniWeb. Didn't realize we were on the Atlantic ocean :)
Maybe we could have a points system to grade questions on how stupid they are. Like "URGENT! My program's broke, please fix it, and be quick about it.". On a scale of 1 to 10, that deserves a 10 for one of the most stupid idiotic posts that occasionally come up.
There's Open Source, freeware and public domain. Almost everyone uses free software of one sort or the other. FireFox is just one of many. And there are a lot of free compilers and editors.
Would I use them? Of course I would (and do). :)
But what does this have to do with "Advertising Sales" ?
Answer to Ancient Dragon:
When I downloaded the SDK I got some samples. none of them uses directsound :(
I found several of them here (on my computer)
C:\Program Files (x86)\Microsoft DirectX SDK (August 2008)\Samples\C++\XAudio2\Bin\x86
Look up the function you want in MSDN -- it will tell you what lib you need. Yes I know that link is for WinCE, but it also applies to desktop win32.
you have to link with the appropriate DirectX libraries. When you downloaded the DirectX SDK you also got a lot of sample programs. Look in them and they will tell you what libraries you need. Or you can just read MSDN to find that out.
win32 api functions
See link in my previous post
Are you using MFC or win32 api functions? When you created the edit box you got a HANDLE to the object. See this article
must be something else wrong because this compiles ok with vc++ 2008 Express
class A
{
public:
void* ptr;
A() {ptr = 0;}
};
int main()
{
A* a = new A;
int* p = static_cast<int*>(a->ptr);
*p = 1;
}
This one also has no problems
class A
{
public:
void* ptr;
A() {ptr = 0;}
};
class B
{
public:
int* ptr;
B() {ptr = 0;}
};
int main()
{
A* a = new A;
B* b = new B;
b->ptr = static_cast<int*>(a->ptr);
}
line 6: >> fstream file(nome, ios::in || ios::out || ios::binary);
You are using the boolean || operator, not the bitwise | operator
Anyone knows somewhere to learn MFC from begining?
Depends on the version of the compiler you are using. But here is Scribble tutorial. There are also several good books you can read.
The rules change slightly in derived classes -- derived classes can not access private members of its parent class. Also non-class functions can access only public members of a class
class parent
{
private:
int x;
protected:
int y;
public:
int z;
parent()
{
x = y = z = 0; // ok
}
};
class child : public parent
{
public:
child()
{
y = z = 1; // ok
x = 2; // illegal (private)
}
};
int main()
{
child c;
c.z = 3; // ok
c.y = 4; // illegal (protected)
c.x = 4; // illegal (private)
}
Is the only reason you are using MFC is to get CString class? If yes then why don't you dump MFC and use <string> instead? The only advantage that CString has over <string> is its Format() method, which is more like sprintf().
opic since 98 to 2009
CString is extict because it is from MFC which is extinct,
I don't know (or care) who told you that but it isn't true. VC++ 2010 still supports MFC.
It works as its supposed to work. rv.i is accessing the private member of its own object.
No -- text files have to be read sequentially from start to finish.
Welcome to DaniWeb (see Web Development forums). We have a few tutorials but you can probably find hundreds of them with google.
1) what kind of database? There are billions of them.
2) Post code.
You mean it crashes like that without even running your program?? My immediate guess is that your program has harmed either the video device driver or RAM chip. Try downloading and running a computer diagnostics program.