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

I didn't get any warnings or errors when I compiled that code with vc++ 2010 Express. Check your code very carefully -- there might be an extraneous character somewhere.

AFAIK that compiler should work ok on XP.

tagazin commented: thanks Ancient Dragon! :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>how can i solve the data files's problem

By writing the program of course :) What have you already written? What don't you understand about the instructions?

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

The *.pch file is of no use outside the project that created it. Its only purpose it to speed up the compile process of a project.

What you have to do is add the *.lib file to the project. There are two ways to do it:
1) Put this in one of the *.c or *.cpp files: #pragma comment(lib,"xmlparser.lib") or
2) Select menu Project --> Properties --> Congiguration Properties -->
linker --> Input. On the rightside of the screen add xmlparser.lib to the "Additional Dependencies" edit control

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

what compiler are you using?

For MS-Windows and Microsoft compilers, use winsock2.h and link the program with ws2_32.lib. Windows does not support Berkley sockets.

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

Did you try this?

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

I just do it like this:

void CMfctestDlg::Sum() 
{
    UpdateData (true);
    this->SetWindowText("Result");
    Result obj;
    obj.Final_Result (m_arg1, m_arg2);
    obj.DoModal();
	
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what do you mean by "cursor base"? How to move the set the screen cursor (that blinking black line or square where you type)? That will depend on the operating system you are using.

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

If you know C/C++ then you know how to read xml files

int main()
{
   ifstream in("filename.xml");
   std::string line;
   while( getline(in, line) )
   {
     // blabla
   }
}

For something more complex you might look at boost libraries because I think it has a parser class

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

Homework??? Let's see the code you have started to solve all those problems. We are not here to do your homework for you.

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

So ???

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

I'm not sure what you mean by that -- "." and ".." should not be processed according to the if statement on line 17 that you posted.

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

>>In c and c++ they are refered to as functions.

I refer to functions inside c++ classes (member functions) as methods. Functions not in a c++ class are referred to as just a function. But maybe the terminology has changed a little since I went to school.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
if(i<n)
             c[k++]=a[i++];
      else if(j<m)
             c[k++]=b[j++];

You need to loop through i and j until i == n and j == m. Note that the if statements are not needed.

while(i<n)
    c[k++]=a[i++];
while(j<m)
 c[k++]=b[j++];

>>for(loop=0;loop<--k;loop++)
Change <-- to just <. You don't want to change the value of k.

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

Read this

If you use MS-Windows you can use your 32-bit compiler to read the file if you use win32 api file/io functions instead of std::fstream. AFAIK there are no 64-bit implements of fstream for 32-bit compilers.

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

0.5 is a double, but 0.5F is a float -- the F tells the compiler to assume its a float and not a double.

>>int main(float time, float charge)

That is wrong. It sould be this:

int main(int argc, char* argv[])
{
   float time,charge;
    printf("How long did car 1 stay?   ");
    scanf("%f", &time);

    charge = CalculateFee(time);

    printf("Car 1 pays a fee of %.2f\n", charge);

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

A simple class

class MyClass
{
public:
   MyClass()
   {
      x = 0;
   }
   int Add(int n)
   {
      this->x += n;
   }
private:
   int x;
};

A normal function outside a class might look like this:

struct MyStruct
{
   int x;
};

int sum(int n, struct MyStruct* s)
{
    s->x += n;
    return s->x;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
float CalculateFee(float time)
{
    float charge = 2.0F;
    if( time > 3.0F)
    {
        charge += (time-3.0F) * 0.50F;
        if( charge > 10.0F)
           charge = 10.0F;
    }
    return charge;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1. You should have used code tags when you posted that stuff. No one is going to read that unformatted code.

>>How can I replace my buffer using malloc which reads unlimited line
Use a linked list.

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

>>can you please get me the details how to get the client from US and UK.

Nope -- I don't know a thing about it, and am not inclined to find out.

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

If you know the basics of C and/or C++ then you should have no problem figuring out how to read that xls file. Afterall, it's nothing more or less than a text file. If you don't have the basics down then forget about reading that file for now and concentrate on learning the language.

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

you can only go 16 bit colors with Turbo C.

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

Looks like you are doing it the hard way

int n1,n2,n3,n4,n5;

while( map >> n1 >> n2 >> n3 >>n4 >> n5 )
{
   // do something with these numbers
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read this. Call the control's GetTime() method, which returns a SYSTEMTIME structure. That structure contains what you are looking for.

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

Yes -- I thought you said you was using a more modern compiler.

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

>>char *argv[100];

You need to initialize all those pointers to 0, like this: char *argv[100] = {0}; Why are you typing in /bin/ls? Doesn't it work with just "ls", like you would type it in the shell?

[edit]I tried it just now and it doesn't work either. Not sure what the problem is.

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

You can't use those interrupts with any of the modern 32-bit compilers. They, and the operating systems, will not permit you direct access to hardware. You have to use standard C functions such as ansi C or win32 api. See these windows console functions

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

Add another pointer -- call it tail or something -- that keeps track of the last node. Then when you need the end of the list it will be easily available without taking the time to traverse the entire list.

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

bad link. Try posting it again.

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

Oh -- yes I misunderstood. By alignment I thought you meant on 1, 2, 4, 16 ... byte boundries.

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

>> // Multiple variables are aligned

The only place that might make a difference in in a structure to avoid holes.

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

Yes, I know that. Did you bother to read the suggestions I posted?

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

Did you start out by creating a project? Read this tutorial (walkthrough)

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

>>lab=&(*lab)->next;

That is destroying the original pointer. Use a different pointer to iterate through the linked list and leave the original pointer unchanged.

Something like the code below (not compiled or tested). You didn't post the definition of struct information, so I'll just assume it contains no other pointers than the pointer to the next structure.

information* node = NULL;
information* tail = NULL;
information temp; // note that this is NOT a pointer!
while( fread(&temp,sizeof(information),1,fp))>0) )
{
  node = malloc( sizeof(information) );
  memcpy(node,&temp, sizeof(information));
  node->next = NULL;
  if( *lab == NULL)
  {
     *lab = node;
     tail = node;
  }
  else
  {
     tail->next = node;
     tail = node;
  }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Probably something like this (untested) code

#include <fstream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;


int main()
{
    std::vector<std::string>  elementVector;
    std::ifstream in("filename.dat");
    std::string line;
    while( std::getline(in, line) )
    {
        if( line == "<et>" )
        {
            std::getline(in,line);
            stringstream st;
            st << line;
            std::string word;
            while( std::getline(st,word,'\'' ))
            {
                size_t pos = word.find('\'');
                if( pos != string::npos )
                    word.erase(pos,1);
                elementVector.push_back(word);
            }

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

include <string>

>>stdev= pow(sum,0.5);

sum is a float, but 0.5 is a double. There are no overrides of pow() that take those parameters. change 0.5 to 0.5F to make it a float.

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

bool, true and false are c++ keywords. Just comment out that enum and it should work ok.

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

>>for (i = 0; i < n;++i){

What will happen if you only input 3 numbers? Answer: the final value of sum will be in the crapper because it will add in uninitialized array elements 4-20.

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

Another way to do it is to use Visual Basic Applications

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

Why not just use MS-Word or Open Office to modify the doc file?

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

I perfor { and } on separate lines, inline methods/functions when they consist of only one or two lines, and int main() instead of void main()

#include <iostream>
using std::cout;

int main()
{
   if( somethod )
   {
      cout << "Somethig here\n";
   }
   else
   {
      cout << "Something else here\n";
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>this calculator won't work
Then why did you bother to post that crap?

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

I already gave you the compare function. Why did I waste my time on this :@

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

to post the code just copy into the clipboard and paste it here in the editor. put [code] /* your code goes here [/code] code tags around the code, as in this example.

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

>>CC = /usr/bin/gcc

try removing the white space on that line

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

>> any ideas on why this would happen?

Yes, but its not worth posting until I see your code.

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

Post code because we can't see your monitor.

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

it would be as below. The code would have been a bit easier if you had not created a vector of pointers . vector<Student> list;

bool my_comp_func(Student*& s1,Student*& s2)
{
    return s1->score < s2->score;
}

int main() {

	vector <Student*> list;
	double average = 0.0;
	double total = 0.0;

	list.push_back(new Student("Louis","Radske",90));
	list.push_back(new Student("Bill","Collins",88));
	list.push_back(new Student("Ted","Blood",78));
	list.push_back(new Student("Tim","Sails",98));
	list.push_back(new Student("Ed","Goodson",85));

	for(size_t z=0;z<list.size();z++)
	{
        total+=list[z]->score;
	}

    average = total/list.size();
    std::cout<<"The class average is  "<<average<<std::endl;
    vector <Student*>::iterator it = max_element(list.begin(),list.end(),my_comp_func );
    cout << "MAX: " << (*it)->score << '\n';
    for(size_t x=0;x<list.size();x++)
    {
        list[x]->print();
    }
    //list.front()->print();
	return(0);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

no, EOF is not a char, and you don't need it anyway, just while( fgets(...) ) will do the trick

>>is there a way to tell strtok to tokenize ignoring all non-letter characters?
Probably not. It might be easier to use a pointer and test each character with isalnumeric() which includes 'a'-'z', 'A'-'Z' and '0'-'9'. Just use isalpha() if you don't want numeric digits

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

I assume you mean on the MS-Windows operating system instead of *nix or MAC.

Well, if the program is written in ancii C or C++ then your list shold be empty because the program should compile on all c or c++ compilers.

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

inside the loop that starts on line 50 keep track of the student who has the highest score. Do this by saving the value of the i loop counter into another variable. For example:

int highest = 0;
for(int z=0;z<list.size();z++)
{
   total+=list[z]->score;
   if( list[z]->score > list[highest]->score)
         highest = z;
}