Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes I could, but give it a try yourself. Its easy to do, just write the loop first and after the loop delete the array. If you wrote that code snippet to allocate the memory then I'm confident you can write the code to delete it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not possible to move the mouse without using some lib or function. There are no c functions to do that, nor are there any native MS-DOS assembly language system calls that support the mouse. Your only option is to call one of the mouse device driver's functions, assuming a device driver is installed on your computer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

delete them in the opposite order that they were allocated. use delete inside the loop, but delete[] to delete the array itself.

2) Not possible. You should create another method which can be called after the memory is allocated.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To the compiler, passing by reference is really no different than passing by pointer. The compiler will treat them both the same (assuming you don't attempt to do something obscure like pointer arithmetic or pointer increment/decrement -- those can not be done with references.). But IMO passing by reference is preferable to passing by pointer because references are less prone to error. As far as I can tell by looking at the assembly code produced by Microsoft compiler, the compiler transforms the reference operator into a pointer then passes the object by pointer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't really use a switch statement based on averages. Its better to use a series of if statements so that you can gest ranges of values

if( average > 90)
   return 'A';
else if( average > 80 )
   return 'B';
// etc etc
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There is a similar problem with that p M that preceeds the month/year. You need to re-check each one of those fields in the data file and make sure your program reads corresponding variables.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The last two arguments have similar problems.

squigworm commented: Very helpful ..Thank You +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

one way to do that is to read it as if it were three different variables

char period;
...
			inputFile >> tempHour >> period >> tempMinute;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, and that feature is quite handy in several ways, for example when creating an array of classes all derived from the same base class.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It probably doesn't really matter one way or the other, the compiler will probably optimize them both the same. Whether or not to use a pointer should depend on other factors. But consider that pointers are a little more dangerous because programmers often fail to clean up when done with them, causing memory leaks.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

damn this is to hard is there an easy way :(

Yes -- pay someone else to write it for you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Probably because the data types of the data file are not the same as in your program. The 4th number on the first line is a float, not an integer, and the next two are characters, not integers. ifstream will produce an error when attempting to read a char into an int variable, and all subsequent input operations will fail. The same problem when attempting to convert a float to an int -- ifstream doesn't know what to do with that deccimal point.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Does this function call and definition not match ?

Bingo :) My guess is that you have two overloaded functions named bookinfo, but neither of them have exactly the same arguments as the one your program is attempting to call. Notice that one passes some parameters by reference while the other two pass by pointer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

can you post the first few lines of the data file?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The only reason I can see why that does not read the file is when inputFile failes to open. Add a check right after line 4 to verify the open succeeded.

if( !inputFile.is_open() )
{
    printf("Open failed\n"');
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

arraysnumber is not an array; its just a single integer. YOu need to declare the parameter something like this: void function3(int arraysnumber[], int arraysize) so that the compiler knows it's an array.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

edit your post to include code tags [code] // your code goes here [/code]

where (which line) does the error occur?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to typecast the base class pointer into a derived class pointer before it can call functions unique to the derived class. Base class knows nothing about those functions. derived_class *pDerived = reinterpret_cast<derived_class*>(obj);

int main(void) {
  base_class *obj;

  obj = new derived_class (10);
  derived_class* pDerived = reinterpret_cast<derived_class*>(obj);     
  obj->func_1();
  obj->func_2();
  pDerived->func_3();
  pDerived->print_y();

  return 0;
}
C++NOOOB commented: Perfect! Solved my problem. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>The loop works fine
No it doesn't. That loop may read the last line of the file twice, assuming there are fewer than MAXENTRIES number of lines in the file.

My guess is that you have just dummied up the code you posted without bothering to copy/paste from the code you really have on your compiler. Just code is nearly useless to us. If you expect help then post the actual code you have, not something that is just contrived.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

sizeof(edgenode) has the same problem as sizeof(g[0]) -- edgenode is an array of pointers. It makes no sense to save pointers because those pointers will not be valid when read back into the program. As I said before, it is not possible to save a linked list in one shot -- each node must be saved.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Already got my Christmas present this year -- Samsung 55" 400+ Hz LED TV, Blue-Ray DVD player, and Bose speakers.

William Hemsworth commented: Awesome :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why does class graph contain an array of edgenode pointers? Is there going to be MAXV number of linked lists? If on the otherhand there is only going to be one linked list then that class doesn't need more than one edgenode pointer, which will be the head of the linked list.

If you want to serialize that linked list(s) then you have to wrote out each node individually -- there is no way to write them all at the same time.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>line 35: ofile.write((char*)&g[0], sizeof(g[0]));

sincfe g[0] is a pointer, sizeof(g[0]) is the same as sizeof(any pointer) which is normally 4 with a 32-bit compiler. What you want there is sizeof(graph). But that won't really do what you want either because it doesn't include the edgenode array other than that array of pointers.

The next thing wrong with that line is that g[0] has been allocated memory but otherwise uninitialized. class graph does not have a constructor so none of its data variables will be initialized to anything other than whatever is in the memory at the time memory location is allocated.

Considering the above, it is no surprise that the read part of that function just reads a lot of crap. Garbage out, garbage in.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is one way to do it -- use stringstream class

#include <sstream>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;

int main(int argc, char* argv[])
{
    int day = 20;
    int month = 1;
    int year = 8;
    stringstream str;
    str << setw(2) << setfill('0') << year << setw(2) << month << setw(2)<< day;
    cout << str.str() << "\n";
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

On *nix you can call the function opendir() to check if a directory exists. You can use fopen() to do that. I believe stat() will also work on directories.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You trying to create a game? You can use game generators like DirectX or OpenGL (google for them, both are free). You might also want to google for sprites.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You mean like this?

void openPasswd(char* users[],char* names[], int maxitems)
{

}

int main(int argc, char* argv[])
{
    const int MaxItems = 20;
    char *users[MaxItems] = {0};
    char *names[MaxItems] = {0};

    openPasswd(users, names, MaxItems);
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No you don't have to use () on your own c++ classes.

class MyClass
{
public:
    MyClass() { cout << "Hello World\n"; }
};

int main()
{
    MyClass c;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

According to this www.DaniWeb.com is owned by NETWORK SOLUTIONS, LLC

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

which is not difficult to implement. Just get the environment variable PATH, then check each of the directories for the given file and report the directory for the first hit. The file might be contained in more than one directory, but all you want to report is the first one.

I don't know about the others.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's funny 'cuz the IP they banned was one globally used by the University. Dani just banned an *entire* campus of potential clients. HAHAA!

What Dani banned Dani can unban.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What is the problem? What have you tried to resolve the problem?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What do you mean by "it doesn't work"?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Is it incorrect to pass "hFind" as the first parameter to GetFileTime()?

No. You need to read msdn for the functions you want to use. Read this. It clearly states the hFile parameter must have been obtained by CreateFile().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How do you know Sleep() doesn't work?? Recall the parameter is milliseconds -- there are 1000 milliseconds in one second.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Where did you get that crappy code from??? Toss it out and forget it.

>> myend = &MyArray[MAX_SIZE];
Wrong -- myend is set to point one element beyond the end of the array, a common mistake. should be myend = &MyArray[MAX_SIZE=1]; >>first = (MyLL *) mystart;
Illegal operation. mystart can not be converted to MyLL structure.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Compare each string one character at a time in a loop. If one string contains a ? then assume it is matched with whatever character is in the other string. If one character contains a * then look at the next character (in your example its a 'g'), then in the other string advance the pointer forward until you find either end-of-string or the first 'g'.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

deleted line 12 -- srand() does that. And its in the wrong place too -- it should appear at the top of main() because srand() should only be called once during the lifetime of the program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You might as well delete the loops on lines 4-10 because that initialization is just undone (destroyed) by line 29.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

yes, that's ok too.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No

int main() 
{

int i;
string list[10]; 
int Quantity = 0;
string line;   

ifstream ifil ("movies.txt"); 


while ( getline(ifil, line) ) 
{ 
    list[Quantity] = line;
    Quantity++;
}

Next you will have to change that sort function to take an array of strings instead of an array of char pointers

void sort( string movies[], int Quantity)
{

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No, the int means the function returns an integer. The void means main() does not have any parameters.

There are three ways to code main(). Any other way is non-standard and may or may not be supported by your compiler. int main() int main(void) int main(int argc, char* argv[])

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In c++ int main() and int main(void); are the same thing. You are free to code it either way, unless your teacher tells you otherwise.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) use getline(), not >> to read each line of the time.

2) you have to put the line that was read into an array of some kind. Line 42 just mearly counts the number of words read and toss out the strings.

move lines 48 and 49 up to just after line 32. Then change the array like this: string list[10]; When the file is read (line 42) add the lines to the array list.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That is Microsoft and they do whatever they want. Microsoft does NOT control the C/C++ standrds committee. Other compilers will (or may) produce errors because void main() is non-standard.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are trying to do it the hard way

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>

using namespace std;

int main()
{
    vector<string> movieList;
    ifstream in("myfile.txt");
    if( in.is_open() )
    {
        string line;
        while( getline(in, line) )
            movieList.push_back(line);
        sort(movieList.begin(), movieList.end());
        vector<string>::iterator it = movieList.begin();
        for(; it != movieList.end(); it++)
            cout << *it << "\n";

    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

void main() just means that the programming doesnt return any value.

Never ever recommend void main() because it isn't recognized by either C or C++ standards. Read this article.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To see if unicode, goto menu Projuect --> Properties --> expand the Configuration Properties tab, select General. Now check the value of "Character Set" -- if its set to "Use Unicode Character Set" then you are compiling for UNICODE. You can turn that off by changing it to "Not Set". When you do that then TCHAR does nothing and all strings will become char* instead of wchar_t*

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you compiling for UNICODE? If you are, then try making filename a TCHAR instead of char*

TCHAR filename[] = TCHAR("C:\\Windows\\filenamehere.exe");
RegSetValueEx(hKey,TEXT("filenamehere"),0,REG_SZ,(LPBYTE)filename,sizeof(filename)/sizeof(TCHAR));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>sizeof("C:\\Windows\\filenamehere.exe");

That will not produce the value you want -- the sizeof(any pointer here) is the same for all pointers (most likely 4). It would be easier to just declare a variable to hold that string so that you don't have it in your program twice. char filename[] = "C:\\Windows\\filenamehere.exe"; With that you can use either sizeof() or strlen() because variable filename is not a pointer.


Your function will not work at all under Windows 7. I get "Access Deined" error on RegOpenKeyEx function. There is obviously a permissions problem somewhere that needs to be fixed even though I am logged in with Administrator rights. I've seen similar problem elsewhere in this os.