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

The first parameter is a function pointer -- the prototype you declared on has a simple void object pointer void (*FktFunction)( void (* RegistFuncPtr)(struct TDevice * newdev), TOnDriverEvent eventcallback); I think you want something like the above. I didn't attempt to compile that, so not sure if it's exactly right or not.


>>(*FktFunction)(TDriverLayer_RegisterDevice, TSMAData_OnNewEvent);

You can simplify that somewhat like this: FktFunction(TDriverLayer_RegisterDevice, TSMAData_OnNewEvent);

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

>>is the below code done using recursion or not?
No. Recursion requires a function to call itself, and I see no indication of that behavior in the code you posted.

>>how can i make the below code take input from a text fiel
Open the text file, then change the code on line 37 to read a line from the file then send it to the push() function instead of the rand() value.

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

wth - "base guitar" ? must be a typo...

I don't think so -- see the link I posted

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

What's the difference between "base guitar" and "bass guitar" ? This is the first time I heard of a "bass" guitar.

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

I can't log in using Firefox. When I click on the Member Login button, nothing happens. The windows for username and password do not appear.
.

I am now in FF version 3.03, logged out. When I hit the Login button at first I though it did nothing, but then noticed the two edit controls next to the login button asking for user name and password -- hard-to-read watermarks. I had no problem logging back in after I discovered that.

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

Ok, deleted temporary internet files, and the problem solved.

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

See thumbnail to see what I mean. I was in Geek's Lounge when I hovered the mouse over Business Exchange.

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

When I'm viewing Geek's Lounge the IT Professional's Lounge is listed under Business Exchange, any other time its listed under that person icon.

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

But why does IT Professional's Lounge` move around? Shouldn't it stay put?

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

Or The Roaming Menu. I'm talking about the IT Professional's Lounge link. Sometimes its in the menu list and sometimes not. Sometimes its listed under Business Exchange menu, and othertimes under Water Cooler (or whatever its named now, don't know what its named because there is no menu title).

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

>>I don't have a C++ compiler to run it
Download one of the free ones.

>>a = c;
That's illegal.

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

Why not put your music degree to work in the IT field. I should think you could get a job at one of the big game houses providing and/or writing music for the games. You might also want to get back in school and get another degree in computer science.

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

you would leave B and poly as they are, just add another long long variable for sorting purposes. When two structs have the same B value the long long will auto sort by poly. This is similar to the approach databases use when more than one field are needed to create a unique key.

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

indices is used to indirectly reference the elements of the other two arrays. IMO the best way to understand the concept is to write a small program and test it out. Sort the array then print out the values of the errors array.

// assume array has been sorted per my previous post
//
// now just simply display the values of the errors array
for(int i = 0; i < 16; i++)
    cout << errors[ indices[i] ] << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Pretty close to real life! Let's hope this poll retains the voters' privacy! Unlike the nasty one by Mister Dave.

I don't care if people know I voted for "that one" :)

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

Banned. I cant delete posts on this board though. Flagged.

But it says you deleted them

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

You want to sort the error array and keep the relationship with the rows in weights array ???

One way is to use another array that contains indices into both error and weights array. When you sort error array actually move the rows in this third array. Use the third array as indirect access to the other arrays.

indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
// sort errors array
for(int i = 0; i < 15; i++)
{
   for(int j= i+1; j < 16; j++)
   {
       if( errors[ indices[i] ] < errors[ indices[j] ] )
       {
             int temp = indices[i];
             indices[i] = indices[j];
             indices[j] = temp;
        }
   }
}

Now to reference weights: assume variable X is an integer that contains the value from errors index weights[ indices[x] ][0]; Or, if that is a little too complex for you, just sort both errors and weights array at the same time. When you exchange elements of errors array also exchange all columns in the corresponding rows of weights.

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

void main(). C and C++ standards require main() to return an int.

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

There are several ways to solve the problem. One way is to create a 64-bit int in the structure that represents both B and poly at the same time, which will result in unique values for each structure in the array. Your program could set that value just before inserting the structure into the array

struct EDGE
{
    int  poly;
    double inv_slope;
    int B;
    long long sortValue; 
            
POINT3D p1, p2;
};

...
sortValue = (long long)B << 32 | (long long)poly;

Now you can code radix sort by sorting the sortValue member variable.

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

That is C code, not C++. Are you sure you are in a c++ class?

for a fstream tutorial click here.

cout is quite easy to learn. First you have to include <iostream> header file -- it does not have a .h extension. Then declare the std namespace.

#include <iostream>
using std::cout;

int main()
{
    cout << "Hello World\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try this

//function to clear all pointers
void clearMemory(bus* &pointer)
{
  bus *next;
  bandMember *current;
  
    
  next = pointer;
  while(next != NULL)
  {
      current = next->memListPtr;
      while(current)
      {
        bandMember *hold = current;
        current = current->memberPtr;
        delete hold;
      }
    bus* hold = next;
    next = next->busPtr;
    delete hold;

  } 
  pointer = NULL;
}

void Add(bus*& head)
{
    bus* node = new bus;
    node->busPtr = 0;
    node->memListPtr = 0;
    if(head == NULL)
        head = node;
    else
    {
        bus* next = head;
        while(next->busPtr)
            next = next->busPtr;
        next->busPtr = node;
    }
}

int main()
{
    bus* head = 0;
    for(int i = 0; i < 5; i++)
        Add(head);
    clearMemory(head);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Gas went down again today to $1.75/gallon.

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

I like my coffee in Kahlúa

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

Ok, so you posted what your teacher gave you. Now post what YOU have attempted.

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

Could be no one here knows what you are talking about. What is "lame binding for phython" ? Of course I know what phthon is. Are you trying to call phython from C/C++ (or reverse) ?

>>Where can I get that simple yet safe DLL to play with CTYPES

You can write it yourself.:ooh:

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

for another example i wrote a program which contained some graphical features
compilers couldent compile it ,exept borland c for dos(even borland c for windows coulden`t compile

As you found out the hard way, attempting to port programs written with ancient Turbo C is pretty tedious -- usually requires 100% rewrite of everything used from dos.h and graphics.h

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

fctThread() does add the names to the pointer in the thread's parameter, but your program just tosses that pointer into the bit bucket (throws it away). Line 99 allocates the pointer, line 100 creates the array and passes the pointer to it, then ---- nothing. The pointer is never saved anywhere, nor is it freed, causing a memory leek to boot.

I can only guess why AddUser() fails to add the structure to the global linked list -- you need to synchronize thread access to all globals so that two or more threads don't attempt to write to the same object at the same time. semaphonres are usually used for that purpose.

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

1) learn to properly format your code to make it easier to read and understand.

2) The for loop on line 80 is not formed correcly

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#pragma warning(disable: 4996)

#define max 10

typedef int TipoChave;
typedef struct {
 char texto;
  
} TipoItem;

typedef struct Celula_str *Apontador;

typedef struct Celula_str {
  TipoItem Item;
  Apontador Prox;
} Celula;

typedef struct {
  Apontador Fundo, Topo;
  int Tamanho;
} TipoPilha;

void FPVazia(TipoPilha *Pilha)
{
  Pilha->Topo = (Apontador) malloc(sizeof(Celula));
  Pilha->Fundo = Pilha->Topo;
  Pilha->Topo->Prox = NULL;
  Pilha->Tamanho = 0;
}  /* FPVazia */

int Vazia(TipoPilha Pilha)
{
  return (Pilha.Topo == Pilha.Fundo);
}  /* Vazia */

void Empilha(TipoItem x, TipoPilha *Pilha)
{
  Apontador Aux;

  Aux = (Apontador) malloc(sizeof(Celula));
  Pilha->Topo->Item= x;
  Aux->Prox = Pilha->Topo;
  Pilha->Topo = Aux;
  Pilha->Tamanho++;
}  /* Empilha */


void Desempilha(TipoPilha *Pilha, TipoItem *Item)
{
  Apontador q;

  if (Vazia(*Pilha)) 
  { printf(" Erro   lista vazia\n");    
    return;
  }
  q = Pilha->Topo;
  Pilha->Topo = q->Prox;
  *Item = q->Item;
  free(q);
  Pilha->Tamanho--;
}  /* Desempilha */


int Tamanho(TipoPilha Pilha)
{
  return (Pilha.Tamanho);
}  /* Tamanho */
 int main()
{ 
 TipoPilha pilha;
 TipoItem item;
//  Apontador p;
  FPVazia(&pilha);
  printf(" digite um texto");
int i=0;
char palavra[30];
fgets(palavra, sizeof(palavra), stdin);
while (palavra[i]!= '0')
{
    for(i=0; palavra[i]!=' ' && palavra[i]!='0';i++)
    {
        item.texto=palavra[i];
        Empilha(item, &pilha);}}
        while(!Vazia(pilha))
        {
            printf(" %c \n", item.texto);
            Desempilha(&pilha,&item);
            if(palavra[i]!='0')
            {
                i++;
            }
        }                   
        getch();
 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>ptr=(unsigned char*)malloc(5*sizeof(unsigned char));

you are only allocating 5 bytes to hold 5 integers! and ptr needs to be an int pointer, not a char pointer. Change that line to int* ptr= malloc(5*sizeof(unsigned int));

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

'ç' has a decimal value of -25, and isdigit() only works with positive signed integer values.

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

stringstream is the simplest way to convert an int into hex string

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

int main()
{
    int n = 255;
    string s;
    stringstream stream;
    stream << hex << n;
    stream >>  s;
    cout << s << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try this:

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

int main()
{
    string name1 = "Alvin";
    string name2 = "Edward";
    cout << left << setw(20) << "Name: " << name1 << "\n";
    cout << setw(20) << "Another Name: " << name2 << "\n";

}
Alex Edwards commented: Is that your real name? =P +5
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It is $1.87/gallon here yesterday, down from high of about $4.20 or so earlier this summer. One station in St Louis is still selling at $3.80/gallon because he said he isn't going to lose over $5,000.

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

>>error string no such file or directory in .h
What compiler are you using? That error would indicate you are usiing something readlly really old, like ancient Turbo C what knows nothing about <string> header file.

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

iostream.h is obsolete (depreciated). use <iostream> (without the *.h extension). Then you have to declare std namespace, which can be done in several ways

#include <iostream>
using namespace std;

or like this:

#include <iostream>
using std::cout;

or like this

#include <iostream>
int main()
{
    std::cout << "Hello World\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you could make one class derived from the other

class A
{
...
};

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

There are several threads about writing your own assembler

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

There are hundreds of reasons you get that problem, so its impossible for us to give you much more info without seeing the code. Try commenting out large portions of the program until the crash no longer happens, that way you can narrow down your search for the problem. Look for buffer overruns and uninitialized variables, especially pointers.

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

>>if((__int64)MAX_NUM % i == 0)
That will result in only ONE int being pushed back onto the vector. You could save alot of processing time by just this: ints.push_back(MAX_NUM);

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

dr dos. I don't know what you mean by "small", but its not a gui, which takes out a lot of bload in operating systems such as *nix and MS-Windows.

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

I have 64-bit Vista Home/IE7, 5 Gig RAM, quad core, and occasionally have a similar problem. Had to use Task Manager to kill it just about a half hour ago. Thankfully, that doesn't happen as often as it does for you.

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

You all have a Wal-Mart close by? Here in USA they are one of the few companies who are doing ok. I have not heard any rumbles about layoffs where I work.

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

when using character arrays the == operator does not compare string content but string addresses, so it will never work. You need to call strcmp() which returns 0 if the two strings are exactly the same. if( strcmp(name[i], "Jack Danial" == 0) . strcmp() is case sensitive, meaning "Jack" is not the same as "JACK". Many compilers have case-insensive compares, such as stricmp() or comparenocase().

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

But can you use VS to write really native, unmanaged code? I wonder.

Yes, it is definately possible for C/C++. C#, probably not, but we are not discussing C# in this board.

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

i'm using dev c++..
what library file i have to download?

To do what?

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

I think you are missing { and } in the code beginning on line 26

Also, you use fflush(stdin) a lot -- not a good thing to do. See this thread. You might also want to follow the other links shown at the bottom of that page.

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

Visual Studio is a development environment in wich you can have compilers for C++, C#,J++,Visual Basic and others. I use Visual C# most of the time and I can write managed and unmanaged code with it. But I like managed code. I can't count the hours I have wasted in C++ on figuring out why my handles and pointers where already in the "twilight zone" when they shouldn't be...
.

As I suspected, you are using VS to write managed code, not unmanaged plain-jane c++ code as most of the rest of us do. Nothing wrong with that, but you provide a solution to a different problem.

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

I tried to add the dll by reference->Add new Reference. then, it shows a pop up window called add reference. There I cant do nothing to add a dLL. Here I'm using visual c++ 2005.

wijitha

Yup, same here. Go back and re-read my previous post about LoadLibrary()

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

From this, it looks like a game of some sorts to me.

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

This is also the C++ forum.

Look again :)