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

Here is an example of event-driven comm. Learn to do a little research and you can usually (but not always) find good information from google.

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

This is an example from MSDN

' Close the serial port.
   MSComm1.PortOpen = False
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Should I allocate memory for it
not necessary -- what you posted is ok.

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

create a bool flag before the loop starts and set it to false. when a swap is made change the flag to true. on next loop iteration if the flag is still false then no swaps were performed during the previous loop iteration.

and please next time use code tags.

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

if you compile my program you can clearly see i have it in acsending

void sortArray( double arr[], int sz )
{
	
}

:mrgreen: :mrgreen: :mrgreen: you have to write code for that function if you expect the array to get sorted.

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

>>But I was wondering if there was a way to skip lines in C
I already answered that question. please re-read my previous post. If you did not understand my answer then ask about the part you did not understand.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
buffer=files[i-1]->d_name;
		rebruk = write(sock, buffer, sizeof(files));

I think this is also wrong. buffer is a pointer to d_name, but attempting to write sizeof(files) number of bytes. If files is an array of pointers to structures, then sizeof(files) will be 4 * number of pointers in that array. You probably mean this, unless files[i-1]->d_name is also a pointer.

buffer=files[i-1]->d_name;
rebruk = write(sock, buffer, sizeof(files[i-1]->d_name));

In that case why use buffer at all

rebruk = write(sock, files[i-1]->d_name, sizeof(files[i-1]->d_name));

If d_name is also a pointer, then you should probably replace the sizeof() with strlen(d_name)+1
In that case why use buffer at all

rebruk = write(sock, files[i-1]->d_name, strlen(files[i-1]->d_name)+1);

Now for the client side:
Since buf is a pointer, did you allocate memory for it, or what does it point to? please post code for this.

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

how is buf declared in that client function? If buf is declared as char* then sizeof(buf) is always 4 on 32-bit compilers.

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

It is not normally possible to just skip lines in a text file. Just read the file from beginning to end until you get to the line you want. If this is going to be done frequently on a file that rarly, if ever, changes then there are some techinquest to index the file for quicker access, but I doubt this is what you will want to do anytime soon.

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

I prefer classical (but don't like opera) and other pop music of my day. I hate most of the music made during the 80s and 90s, but my parents said the same thing about my generation's music too. I don't watch music videos very often but the ones I have seen were pretty good, so I suppose the music being written today is better than the music during the past 20 years.

The best test of any music is the test of time. If a song is still heard 20 years from now then it is probably a good one.

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

http://www.theregister.co.uk/2002/04/30/preinstalled_windows_aargh_i_cant/

You be the judge.

That certainly sucks cannel water:mad: If I buy the hardware it is certainly mine to do what I want to. But I don't buy the hardware with XP preinstalled, so its not a problem for me. But I can understand the problem for the millions of other users and schools.

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

'Onolicious ...nuff said.

I hope that means Yummy:mrgreen:

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

100,000 rows is just an average size database -- large ones have millions of rows. If you have an address in table A that is not in table B then you want to correct the address in table A. How are you going to do that? How do you know what address it should have been? If the address is "ABC" how will the program determine that it should have been address "XYZ" instead of "HIJ" or any of the other 100,000 or so rows in table B?

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

the result set has 18 columns on each row, you sprintf() statement is attempting to use 19 columns (row[0] thru row[18] is 19 columns).

char *mon;
    char *day;
    char *yr;
    time_t tvec;
    struct tm* dtime;

    time(&tvec);
    dtime = localtime(&tvec);

    *mon = dtime->tm_mon + 1 ;
    *day = dtime->tm_mday  ;
    *yr = dtime->tm_year  ;

That is wrong. mon is an ininitialized pointer that points to some random location in memory. Here is how to code that section

int mon;
    int day;
    int yr;
    time_t tvec;
    struct tm* dtime;

    time(&tvec);
    dtime = localtime(&tvec);

    mon = dtime->tm_mon + 1 ;
    day = dtime->tm_mday  ;
    yr = dtime->tm_year  +1900;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I find IE7 more difficult to use then IE6 despite the new tabs. I still like FF better and use it all the time at home. I'm not allowed to use FF at work -- only IE.

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

We make this each year for my Christmas office party and for home. It takes awhile to make, but worth it. Make well ahead of time.


Preheat oven to 375 degrees fahrenheit.
Preparation time: 1 day.

3 eggs
1 cup sugar
1 cup canned pumpkin
1 tsp vanilla
1 dash salt

Mix very well, then add the following
3/4 cup white flower
1 tsp baking soda
1 tsp cinnamon

spray a cooky sheet with Pam or similar product. Spread the above mixture thinly on the cooky sheet.

Bake until tooth pick test is clean.

Flip the cookie sheet upside down onto a damp a tea towl. Remove the cooky sheet and roll like a jelly roll. Put in freezer for 30 minutes. VERY CAREFULLY unroll it to prevent cracking.

Filling:
1 cup powered surgar
1 tsp vinilla
1 8 oz cream cheeze
2 tbs butter or margerine
optional -- English Walnuts or peacons

Mix well, spread on top of cake, then VERY CAREFULLY roll up. put the roll on wax paper and aluminum foil under that. Roll up, and put back into freezer for several days.

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

Besides this, I am quite happy with our system. I just see the need for vast improvements. There are scores (see, 100's of 1000's, if not more) of American people who go daily without their prescribed medicine, (the very medicine that just might cure their ills) because they cannot afford to pay for it and they do not have insurance. Medicine has become the new Mercedes, Nike, Apple-- designer quality at designer prices. Capitalism run amock. How inspiring. :rolleyes:

I agree -- there is no such thing as a perfect system. I mostly disagree with the term "pathetic Health system of the U.S. " -- it is better than most.

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

There are many breakthroughs that occur. I do not disagree with this. Lives are saved. But in the majority of cases, the symptoms are treated, not the root of the disease. This is Western medicine; Large companies do not make large profits from cures but from prolonged use of their products that simulate an awkward "improvement", that is, some symptoms digress while new conflicts grow from:

  1. Side Effects from new treatement\ medicine
  2. The weakening of the human system from the chemicals, err, "medicines" :twisted: prescribed, hence, making the person(s) more sick in the long run

I am a huge supporter of science and research, but I will not sit here and say I am absolutely mad for the pathetic Health system of the U.S.

And sometimes, the grass is actually greener. Perhaps? :surprised

If you think you can do any better than those scientists -- be my guest! They will be more than happy to allow you to work along side them if you are qualified.

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

please use code tags to maintain spacing and make it easier for everyone to read. If you do not know how to use them, then please read the articles in the links in my signature below.

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

The problem is in function readStocks() -- it attempts to read beyond the legal boundries of the array. Here is the correction

void readStocks(double stocks[][NUMDAYS], string stockName[], int & numStocks )
{
	string name;
	while (infile >> name ) 
	{
		stockName[numStocks] = name;
		for (int i = 0; i < NUMDAYS; i++)
			infile >> stocks[numStocks][i];
            
		numStocks++;
	} 
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>but what is a container?

an array, std::vector, std::list, etc.

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

you can use the FoxPro ODBC driver

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

Please use code tags when posting code. Read the information in the links below.

This is how I code it in c/c++:

for(a = 0; a < highSubscript-1; ++a)
{
    for(b = 0; b < highSubscript; ++b)
    {
            if(array[a] > array[b])
            {
                temp = array[a];
                array[a] = array[b];
                array[b] = temp;
             }
      }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think this is a case of "gass is always greener on the other side of the fence".

>>do the Billions spent on medical research actually cure anything significant
Of couse it does. One example: I went through angioplaty (heart) surgery a year ago. This was first approved for use in USA in 1994. And there have been some improvements since then. Hospital stay is only overnight. There are medical breakthroughs all the time -- just because Christopher Reeve and Michael J. Fox have not been cured does not mean a cure will never come.

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

did you even read the story? He is far from destitute, and IS indeed getting medical care.

But now, weak from chemotherapy and armed with a desire to pass on his belief in random kindness, Secret Santa has decided it's time to reveal his identity.

He is Larry Stewart, a 58-year-old businessman from the Kansas City suburb of Lee's Summit, Mo., who made his millions in cable television and long-distance telephone service.

If health care in USA is so bad why do people come here both legally and illegally from all over the world to get it? I have read a few of the horror stories from other socialized countries such as UK, canada and France. There is a two year waiting list to see a doctor -- where I live I can get an appointment within 24 hours if I need to.

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

"People who are filthy rich like that have an obligation to use their welth for the betterment of mankind. "

It is good that the wealthy do give to so many charities as well as hospital buildings etc.

But I only hope that attitudes like this never make it into laws. The wealth envy of some people is simply amazing.

Attitudes like what?? Are you implying I am envious of their wealth? :cheesy: :cheesy: :cheesy: :cheesy: :cheesy: They can have it as far as I am concerned because great wealth causes more problems then it resolves. The stock market drops just a tiny bit and Bill Gates looses millions of dollars. Me? I don't worry about it, in fact I rarly even think about the stock market.

You are putting words into my mouth that are not there.

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

Does anyone know where I can find the pthread library for Linux? And I don't want any rude "go google it" responds. I tried that, and all I came up with was one download available for win32.

Thats what you are going to get -- google for "man pthread" and google will return links to the linux man pages. If you want linux functions always google for "man <function name>". Doesn't your linux installation also have the man pages installed? on the command line you should be able to do the same thing as google.

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

>> scanf("%d", &av[y]);

you have to pass a pointer to scanf() as shown above

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

>> scanf("%d", av[x]);

replace variable x with y.

there is no need to pass variables y or z to function avg. Just make them local variable in that function.

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

One writes a tutorial to teach others how to do something. If you don't know how to do it either you should not be writing a tutorial about it. Why don't you hold off writing the tutorial for a year or so until you have some experience under your belt. The web is littered with bad tutorials and you don't want to just add yours to that list.

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

Pointer of type void can point to any type of data if thats what you asking while int type pointers point only to int data and char type pointers point to char type data.

That is not true. You can make char* point to int* and vice versa. That happens frequently, especially in database and socket programming.

Here is an example:

int x = 123;
char buf[5];
memcpy(buf,&x,sizeof(int));
// now buf contains the binary representation of the integer
//
// convert back to int
int y = *(int*)buf;

>>But, so how can I find out what my restrictions are to pointer types char*, int*, and void* ?
There are none that applies to one type of pointer an not to the other types. typecasting may be necessary to convert one type of pointer to another, as shown in the above example.

Alignment does NOT change the size of a structure, only the address where the object is located. Packing will change the size of the structure by either adding or removing holes. If you want to remove all holes from the structure pack the structure on 1 byte alignment as in the example below. Change the value of the pack and you will get different structure size.

#pragma pack(1)
struct address
{
	char *name;
	char *street;
	char *town;
	long int number;
	long zip;
	char state[2];
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Microsoft compilers has an alignment option to align data on 1, 2, 4, 8, or 16 byte boundries. I think Dev-C++ and other compilers do that too. This is to help improve memory access time.

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

I still have VC 1.52C -- the last MS-DOS compiler. And it still works, if you want to write 16-bit console programs.

It doesn't really matter how old your compiler is if it does what you want it to do. But don't assume you can learn to write good c++ that meet current IOS standards with them because you can't.

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

This came up on another thread, rather that "pollute" that thread with a side issue, I'll start a new thread.

The issue is; Is it better to just to individually declare the
members of std to be used in a program, or is the global declaration "using namespace std" being unjustly maligned as a "global polluter".

For an authoritative answer, I went to the master himself, Bjarne Stroustrup, "The C++ programming Language" special edition, printed Jan 2006.

While he generally frowns upon the use, or more precisely,overuse of global declarations, due to the possibility of ambiguity, he does make a distinction between custom namespaces and the standard library.

The problem comes up if you start naming global variables associated with a namespace.

Morerover, unused names are NOT consiered errors
"When libraries declaring many names are made accessable thorough using-directives, it is a signifcant advantage that clases of unused names are not considered errors" (page 847).

All in all , it seems poor ol' using namespace std is just misunderstood and benign if used properly.

Who the heck want's to write std:: in front over everthing if you don't have to? It is however, recommended to do so with custom classes ie;
CustomClass::

That is the distinction!

For very small programs like one might write in college or HS I see nothing wrong with "using namespace std". But in larger commercial programs that probably should not be used due …

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

Ancient Dragon:

I appreciate your help and compassion.

Green dragons have little, if any, compassion. :mrgreen:

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

how about a program like what you see in resturants to calculate the customer's bill. Has a menu of food items, you select the items you want and it calculates the total, tax and tip. It could also keep track of hourly, daily, weekly and monthly totals -- total sales of each menu item. You can get pretty elaborate with this.

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

>>#include <iostream.h>
that file is obsolete, unless you are using a realy old compiler such as Turbo C++

#include <stream>
using std::cout;
using std::endl;
using std::cin;

>>39 C:\Dev-Cpp\Statics Project.cpp name lookup of `i' changed for new ISO `for' scoping
i declared in the for loop only has scope in the for loop. VC++ 6.0 will allow it to have scope throught the function, but that is wrong. If you want it to have scope throught the function than use C-style declaracion and declare it at the beginning of the function.

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

"C++ is a general-purpose, high-level programming language with low-level facilities. It is a statically-typed free-form multi-paradigm language supporting procedural programming, data abstraction, object-oriented programming, and generic programming. Since the 1990s, C++ has been one of the most popular commercial programming languages." (taken from wikipedia

For someone who knows nothing about programming, or "or just a random person reading a random article online.", that paragraph is totally meaningless and the reader will probably stop reading right there.

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

a class can have more than one constructor. write another constructor that takes the parameter you want.

class Class1
{
public:
       Class1(); // default constructor
       Class1(int array[10], int size);
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't reall know pascal, but most languages are pretty much the same. You can do it one of two ways:
1. read the file one character at a time and write the character just read to another file. When a space is read replace it with a tab and write the tab instead.
2. Read the entire line, then search the line for spaces. When a space is found replace it with a tab. Finally wrote the line to another file.

If you still have problems, please post the code you have so we can see what it is doing;

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

>>cin >> sentence;
there is nothing wrong with that while loop. The problem is the line above -- the extraction operator >> stops at the first space. use getline() instead.

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

Here is some pseudocode code

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

why?

There is always more than one way to do something and often one way is just as good as any other. Some things are just a matter of programmer preference. Some programmers don't like declaring "using namespace std" becuse they claim it brings everything in std namespace into scope. Myself, I say "so what? -- the compiler can handle that very well, thank you". But there is nothing at all wrong with not doing that either.

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

>>I demand that I have some usefullness longer than 3-4 years.
as we have said before, several times, you can still use MS-DOS version 1.0 if you want to, and I think there are still a few people who do. But you will have to upgrade the os to something newer if you want to run some of your favorite programs that you mentioned previously. There is no reason why you can't run Windows 2000 for the next 20 years if you do not plan to upgrade the programs you run on that os.

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

>> i think the the Include should be:
>> #include <string.h>

string.h is used in C programs. C++ should use cstring as the OP posted. He did it correctly.

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

>> while (!cin.eof())
what does cin have to do with readStocks() function?

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

It seems you have taken the long way around with that entire function. This should do it.

//creates a new String by adding current
//String to rhs
String String::operator+(const String& rhs)
{
    String temp;
    temp = itsString + rts;
    return temp;
 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Nobody said you have to buy Microsoft operating systems. You are free to install any operating system you wish, whether it is one of the free versions of *nix or something else. If you don't like Microsoft then buy a MAC.

>>My point here is: Why do I have to pay for OS that I've already paid for? Several times

That is not true. When you upgraded from Windows 2000 to XP you bought a new operating system. XP is not the same os as W2K. And W2K is not the same as NT 4.0. They are all different. Nobody says you have to buy those new versions of the os.

And I hear Vista will be obsolete before it hits the store shelves. Microsoft is already working on another os.

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

maybe using an uninitialized pointer ? Can't say for sure until you post some code.

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

Time library?

all the functions in time.h