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

>>//compiler error: a[1][0] undeclared identifier
Another reason for that error that no one has mentioned is that the class is attempting to use that array before it has been declared. If the class is in a header file then you will also have to put the array declaration there. The easiest way to do that is to make the array a static member of class Y. If you don't want to do that then you will have to do something like this:

class X
{
  // blabla
};
extern X* a[10][10];
class Y : public X
{
public:
    func()
   {
      a[1][0] = reinterpret_cast<X*>(this); 
   }
};

X* a[10][10];

int main()
{

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

since the file is in binary mode you can write the matrix in one big swoop instead of one element at a time mat_file.write(reinterpret_cast<char*>(mp), row_sz * col_sz * sizeof(float)); With that you can delete that entire loop. And read it back with that same line, except change write to read.

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

If you are lucky and if you haven't change the code very much you could get 0 memory leaks. You should make a backup.

The memory leaks I was talking about was in the libraries, not the OPs program. The writers of those libraries may have just been too lazy to clean up after themselves when finished.

I tried to compile those libraries and had to change the file extensions from *.c to *.cpp in order to get them to compile with Code::Blocks because they contained c++ code. I don't know how the authors ever got them to compile as C files.

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

Instead of one big array, read them into an array for each group of albums, similar to the way the file is arranged. And use a vector<string> instead of an array. If you using vector then you can use std::sort instead of coding your own sort algorithm.

vector<string> Christmas;
vector<string> Gospel;
vector<string> BoodSweatTears;

...
std::sort(Christmas.begin(), Christmas.end());
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I tried but it didn't work, can u specify why please

Post your code because I can't see your monitor.

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

Of course its possible -- but that was not your previous question. Its all in the format specification string - you should read about it and become familiar with it so that you don't have to post all those questions. Not that I mind answering them, but it is to your advantage .

cin >> FileName;
sprintf(filename, "%s%d.%d.%d.%d", FileName, counter, A, B, C);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what compiler are you using?

Take the error messages one at a time, then recompile to get a new list. For example, main() is missing declaration of variable i in a lot of places. The declaration of i in the first for loop is only valid for that loop. I'd suggest declaring it at the beginning of main(), like you did variable x

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

Same syntax as stated before, just add more %d parameters in the format string, such as sprintf(filename, "test%d.%d.%d.%d", counter, A, B, C); There is no limit to the number of parameters you can pass to sprintf(), just make sure the type and number of parameters correspond to the format string.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
sprintf(cmd,"python mypyfile.py %s",args.c_str());
   system(cmd);

You could do it this way to, to avoid using C character arrays.

string args = "python mypyfile.py ";
    for(int i = 1; i < argc; i++)
    {
	args += ' '; // add space between args
        args += argv[i];
   }
   system(args.c_str());
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

See my previous post -- I added a line to put a space between the arguments.

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

Of course there is

int main(int argc, char* argv[])
{
    string args;
    for(int i = 1; i < argc; i++)
    {
        args += argv[i];
        args += ' '; // add space between args
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use sprintf() to format the name, i.e.

char filename[255];
sprintf(filename, "test%d.txt", loop_counter);

Its the same concept that I posted yesterday in post #2 to this thread.

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

It seems the problem is fscanf() -- it will only read up until the first white space( spaces, tabs, ets ). If you need the entire line then use fgets() to read the line and then parse it -- call strchr() to find the colon then extract the rest.

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

between lines 15 and 16, just use string's find() method to locate the = symbol and then extract the remainder

size_t pos = songTitle.find('=');
if( pos != string::npos)
{
    songTitle = songTitle.substr(pos+1); // bypass the = 
}

This assumes the string is something like this song title=Hello Dolly

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

The problem appears to be in winbgim.a -- The function cls_OnClose() calls exit(). If you download the source to that library you can change that behavior. But if you do that it may have other unintentional consequences, such as memory leaks.

tux4life commented: Nice answer! +14
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

might be useful to provide a link that explains that function so that people here know what you are asking. Also state the operating system and compiler.

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

search these links Some of them are very expensive -- $3,000+USD

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

post the class then we can discuss how to implement to >> operator.

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

My prediction is that Chrome will not have any impact on IT other than maybe for hobbyists. If it just sits on top of *nix then why bother with it?

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

This version of the same program will also catch special keys, such as <F1>. I make such keys negative to distinguish them from normal keys, but some people also just add 255 for the same purpose.

int main()
{
    int c;
    printf("Enter something\n");
    while( !_kbhit() )
        Sleep(100);
    while( _kbhit() )
    {
        c = _getch();
        if( c == 0 || c == 224)
        {
            c = - _getch();
        }
        printf("%d\n", c);
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This worked for me, using vc++ 2008 Express. But also note that conio.h is non-standard and not supported by all compilers.

#include <windows.h>
#include <conio.h>
#include <stdio.h>
int main()
{
    int c;
    printf("Enter something\n");
    while( !_kbhit() )
        Sleep(100);
    while( _kbhit() )
    {
        c = _getch();
        printf("%d\n", c);
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The 910 was probably a typo -- funny, but a typo nontheless. And I've seen others here (such as Davy) make similar remarks in other threads. :)

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

Welcome to DaniWeb and hope you joing in the discussions here. Feel free to browse all the forums and get acquainted.

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

Hey AD, where are you increasing i ?

Oops! Nice catch :)

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

If you want the C method

char iobuf[255];
long ints[255] = {0};
int i = 0;
// get each line of the file
while( fgets(iobuf, sizeof(iobuf), fptr) != NULL)
{
    ints[i] = atol(iobuf);    
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Each has its own purpose: MyClass A; will disappear from view then the function exits (unless its global), and you can not specify the type of object, whether it is grandfather of class B or class C. The only way to do that is to use a pointer.

class BaseClass
{
   // blabla
};

class Derived1 : public BaseClass
{

};

class Derived2 : public BaseClass
{

};

int main()
{
    vector<BaseClass*> bList;
    BaseClass* pBase = 0;
    if( <condition1> )
      pBase = (BaseClass *)Derived1;
   else
      pBase = (BaseClass *)Derived2;

   bList.push_back(pBase);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I agree with that 1000%!!!! :icon_razz:

If 100% contains everything possible, then how in the world could you possibly agree more than 100% ???

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

Cets are not the primary thing employers look for, but they may make a difference in distinguishing you from the other guys with the same education and experience.

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

Since you didn't say what operating system or version you are using, my guess was to move it here.

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

There is no such concept on MS-Windows operating system like there is on *nix, except to use win32 api FindFirstFile() and FindNextFile().

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

Microsoft compilers no longer supports generating makefiles. Instead, it has a command-line tool to use the solution file. See this article.

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

inheritence means something like this: Class B can call the function from class A because class B inherited everything from class A.

class A
{
     void SayHello() { cout << "Hello from class A\n"; }
};

class B : public A
{
public:
   B() { SayHello(); }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, the mod operator might be a quicker way to convert it.

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

If the military time is past 12:59 then just subtract 12. For example: 1300 - 1200 = 1:00 p.m.

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

jazzman: what is that code going to do when count is two or more digits? If you want to use character arrays then use sprintf() to format the string. sprintf(filename,"test%d.txt", count);

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

try this:

#if defined _WIN64 || defined _WIN32
cout << "This is Windows." << endl;
#endif
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Answer here. Next time try googling for the error number and you will probably get the answer you want.

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

The above doesn't give a compiler error for me, although it doesn't evaluate the or condition.

If using a Microsoft compiler you have the wrong macros #ifdef _WIN32 || _WIN64

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

Its easy --

#include <string>
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
    string filename, temp;
    for(int i = 0; i < 5; i++)
    {
        filename = "test";
        stringstream str;
        str << i;
        filename += str.str();
        filename += ".txt";
        cout << filename << "\n";\
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you know VC6 then you won't have any problems learning VC++ 2008.

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

Hey AncientDragon,

thanks for the great visual reply. I tried your method in MSVC 2008 and it works. Unfortunately I have all of my code in MSVC 6.0 so I get compile errors if I use MSVC 2008. Do you know how to implement your method for MSVC 6.0, if I double click on button I get a "Push Button Properties" window, is there a way to get a "add member function" window in MSVC 6.0??? Thanks for your help.

Colm

That was vc6 that I posted. MFC for VC6 and VC2005/8 are not compatible -- Microsoft made a lot of changes to MFC including replacing many classes with templates.

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

without buying $$$ some expensive profiling programs, that would be about the simplest way to do it.

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

????

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

two threads merged.

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

Below are three pictures -- The first shows the basic main dialog with one "second" button. The second shows the window after double clicking on it, and the third shows what happens after hitting the Ok button

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

To get a list of all the *.cap and *.inf files you need to call win32 api functions FindFirstFile() and FindNextFile(). This would be very simple to do in a managed CLR program, but somewhat a mess in plain c++ programs.

vector<string> capList;
WIN32_FIND_DATA data;
HANDLE hFile = FindFirstFile("c:\mydir\*.cap", &data);
if( hFile != INVALID_HANDLE_VALUE)
{
    do {
         if( strcmp(data.cFileNam,".") != 0 && strcmp(data.cFileNam,"..") != 0 && !(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
          capList.push_back(  data.cFileNam );
   } while( FindNextFile(hFile, &data) != ERROR_NO_MORE_FILES);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It would be much simpler to read the file an entire line at a time, then search the line for <order> tags

string line;
size_t pos;
while( getline(fin, line) )
{
    if( (pos = line.find("<order>")) != string::npos )
    {
          string name = line.substr( pos+1 );
          pos = name.find("</order>");
          name = name.substr(0, pos);
          // now you have the text between <code> and </code> tags
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

something like www.howcast.com

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

All those links are already available in your control panel.