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

do you have to use a vector? It would be simpler to just use a std::string.

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

convert the integer to std::string (use stringstream for that), insert the commas, then display the string. There is no function that will do it for you.

If you use C#, VB.NET or C++/CLR you're in luck because WriteLine() can do it.

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

java is pretty much operating system independent, meaning write it once and run it with no further action on any os that supports java. C and C++ languages are not -- that is you have to compile it for each target operating system. On MS-Windows you could write the C function(s) as a DLL, but that will only run on MS-Windows. If you want to use the same function on *nix then you would have to compile it on a *nix box and probably put them in a shared library (*.so). Then if you want the same on another os you would have to compile the C code on those operating systems too.

Whether it runs faster on a 64-bit computer than it would on a 32-bit computer would depend on the program and the compiler. You will have to run a compiler that can generate 64-bit code, 32-bit compilers such as VC++ 2008 Express can not do that. But you can use 64-bit integers on most modern 32-bit compilers. Here is an article that shows the maximum values of different size integers.

>>I want to start two functions at the same time!
Check out threads.

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

1) post *.cpp, *.c and *h files, not *.docx files. MS-Word files can contain viruses that we don't like.

2) your program contains a couple missing semicolons and include files. When you using cin and cout you need to include <iostream>

3) A misspelled function name -- watch the capatilization because cin.getLine(... is not the same as cin.getline(... .

4) TraverseList(pHead); as it appears in main() is not a valid function. You are trying to call a method of a class without a class object. If you want to call that class method then you can make it a static method and call it like this: CNode::TraverseList(pHead);

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

The variable name on line 3 is the same as the function name on line 1 -- bad idea. Read this article. Your program has to call one of the checkboxes methods to find out whether it was checked or not.

_siren2 commented: pointed out a few things and the users post helped me a lot +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you know the answer in line 9 what makes you think it would be any different on line 10? Afterall, both lines 9 and 10 are passing the char variable by reference to the functions.

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

pass it the same as anything else

void foo(char *c)
{

}

int main()
{
   char c = 'A'
   foo(&c);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Also see the freelance sig links in this guy's post

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

an unsigned char variable is only a value between 0 and 255 (0 and 126 signed). That means it can only contain a single numeric digit -- if you look at any ascii chart you will see that the digit '0' has a numeric value of 48, the digit '1' is 49, etc. When casting an integer to char you have to be careful that the value of the integer is between 0 and 255. Any greater value and the result of the typecase is undefined, meaning it depends on how the compiler decides to handle it.

Instead of trying to typecase the integer you should probably want to convert it to a series of ascii digits. If you have an integers value of 2048 then you will want to convert it into a series of digits '2', '0', '4' and '8'. One way to do it in C language is with sprintf()

int val = 2048;
char buf[10];
sprintf(buf,"%d", val);

The c++ way of doing it would be stringstream class. But since this is a C forum I doubt this is what you want.

#include <sstream>
...
...
int val = 2048;
std::string result;
stringstream str;
str << val;
str >> result; // convert integer to string of characters
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

'm sorry to say that, but i'm not here to joke. I'm going thru a family emergency and thats the reason need some help. Otherwise i never ask someone else to do my assignment.
please let me know if someone will be able to help.

thanks a lot in advance

raj

Then drop the course and take it again. Or ... deposts lots of $$$ in my PayPal account.

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

Deposit $10,000.00 USD into my PayPal account and I will do it for your. Otherwise, spend some midnight oil and do it yourself.

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

Yes of course it can be done. Suggest using cURL library.

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

Not really.. The links on my sig shouldn't count as spammy at all. They are not selling anything, i don't get a profit from anything, and they are all very programming related.

First one sends you to my site i made, a site *solely* devoted to wxPython tutorials. Very relevant to people who visit the python forum where i mainly post.

The others are links to a chat client that will connect the user to the daniweb irc channel.. again, i am failing to see in any way how that could be spam.

I think here that you are i have different definitions of spam.

According to DaniWeb Rules, the definition of spam is:

Do not spam, advertise, plug your website, ...

So if Dani made signature links adhere to the Rules just like normal posts then your signature links would be considered spam.

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

you mean something like this? You can either provide a file name on the command line or redirect a file into the program like this: myprog <main.cpp

void foo(istream &in)
{
    string line;
    while( getline(in, line) )
        cout << line << '\n';
}

int main(int argc, char* argv[])
{
    if( argc == 2)
    {
        ifstream in(argv[1]);
        if( in.is_open() )
            foo(in);
    }
    else
        foo(cin);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That file does not contain a class names CNode.

And post your attempt to solve the problem.

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

When you call malloc() or calloc() you have to tell it how many bytes of memory you want allocated. In the case of the array, you told it you wanted to allocate SIZE * sizeof(int) number of bytes. When SIZE is defined as 5 and sizeof(int) is 4 then free() will allocate 4*5 = 20 bytes of memory. malloc() searches its list of free memory and returns a pointer to some block of consecutive bytes of memory that is at least (meaning it could be larger) 20 bytes. So when you call free() you are telling it to put that block of 20 bytes back into the free memory pool so that it can be re-used again. The memory doesn't just magically disappear -- the memory is still there its just that your program can not use it again until the program calls malloc() again.

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

my keyboard is not working with window vista

Here is a Tutorial that shows you how to fix it.

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

What language did you use to write that program? In C and C++ there are a few win32 api function calls you need to make in order to make the program run with admin privileges. See this article and the links at the bottom.

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

The rule is -- one free() call for each malloc() or calloc() call. You can not free() something that was never malloced. In the case of the linked list, each node of the list was allocated by calling malloc(), therefore each node must be destroyed by calling free(). In the case of the array, there was only one call to malloc(), therefore there need be only one call to free().

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

Post your attempt to solve the problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
void fillCities(WeatherInfo Rain [], int &NumCities)
{	
    ifstream infile;
	infile.open("prog1.txt");
	string CityName;
	int i = 0;

	while ( getline(infile, CityName) )
	{
		Rain[i].city = CityName;
		infile >> Rain[i].TotRain;
		infile >> Rain[i].TempHi;
		infile >> Rain[i].TempLo;
        infile.ignore();
		i++;
	}
    infile.close();
	NumCities = i;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>As for the end of file, i have to use it because i'm not supposed to know how much data is being presented

My comment still stands. Re-read it again to understand what I said about it and how to correct it.

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

And also give them the power to be able to ban users with spammy sigs! That ReplicaWatches thing is really annoying me :S

If they did that then DaniWeb would lose 95% of its members, including yourself.

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

Don't type in all upper case because it means you are screaming and yelling at us.

You need to understand pointers if you want to understand that program. Here is a good paper on pointers by DaWei

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

Form1.Show() ???

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

First move lines 15, 24 and 26 down into fillcities() function. There is no reason for ifstream to be global.

You can combine lines 38 and 39 like this: while( getline( infile, CityName ) ) . There is no need to use eof() like that because it doesn't work the way you think it does. eof() is only detected after an attempt to read something, not before.

Post a few lines of that data file.

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

On line 8 print the value of s on each iteration of the loop then you can see why you get that output. If you use a scientific calculator you will see that (1 & 128) is 0. Then 128 > 1 is 64. (1 & 64) = 0. 64 > 1 = 32. etc.

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

>>it doesn't matter that the variable that was returned goes out of scope.
Of course it does indeed matter. Returning a reference as in your second code snippet is very similar to returning a pointer like this:

int* foo()
{
   int a = 10;
   return &a;
}

Both the reference you posted and the pointer I posted above are wrong and will most likely cause problems for the calling function.

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

Your syntax isn't correct, but....

I don't see anything wrong with the syntax he posted. int* q = a; is perfectly valid as long as a is an array of integers.

[edit]Oh, I think you meant int &p=a; , which is illegal.

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

Replace the list class with std::vector and std::sort

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

You don't use strlen() to get the length of std::string object -- use its length() method

if( f.length() < s.length() )
{
    swap(f,s);
}

Now do that for all combinations if the strings f, s, t, and fo;

Also, a much better way to format your code is to align all the if statements up, unless they are nested, because it makes the code much easier to read and understand.

if( a < b )
   swap(a,b);
if( b < c )
   swap(b,c);
if( c < d )
   swap(c,d);
// nested if statements are like this
if( a < b)
{
    if( b < c)
    {
        if( c < d)
        {
             swap(a,d);
        }
    }
}
i_luv_c++ commented: you are awsome :) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what are the error message(s) ?

lines 9 and 19: why did you stick those returns in the middle of those if statements? That makes line 10, 11, 20 and 21 unusable because they can never be executed.

Mising } between lines 12 and 13.

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

just add showArray() function call on line 51 of the code you posted, just before the end of that do loop.

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

Are you executing bcc32.exe from a command prompt or from Windows Explorer? You can't do it with Explorer.

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

I suppose you could multiply everything by 100 do the integer division, then divide the final result by 100. But 14.3 can not be stored as an integer, so I assume you will just want to print it, such as printf("%.1f\n", (float)1430/100);

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

If you know the buffer will need 8 seconds of data then why not just allocate it all at the same time? Calling realloc() will work too, but will be more time consuming than allocating it all at the same time.

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

You can try MinGW, which is the MS-Windows port of g++. Download it directly or get it with Code::Blocks IDE.

If MinGW doesn't support the files then you will have to redesign some parts of your program.

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

zlib I think was written in C language, not C++. If you want to compile it as c++ then there will most likely be a lot of places that require minor changes, such as typcasting void* to something else, such as zcpr.next_in = (Bytef *)FilePtr;

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

>> setw( 10 ) << 3

That, in C would be printf("%10d", 3); >> setprecision( 2 )
That's the same as printf("%.2f", sales[ i ][ j ]);

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

So what's the big deal about writing that operator overload ? I'm guessing those containers need that operator so that they can make binary searches. If the data is not ordered then they would have to resort to simple sequential linear searches.

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

read each line of the file, then search the line for each of the key words you want to use. For example

std::string line;

if( line.find("VELOCITY") != string::npos)
{
   // blablas
}
else if( line.find("LAT_1") != string::npos)
{
  // blabla
}
// etc. etc.

>>I'm just beginning to programm in C,
This is the c++ forum, not c forum :)

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

I have the output window always docked at the bottom of the screen so that its always visible and not a popup. On my setup what you are calling the Error List window is the same as the output window, that is the error list is shown in the Output window.

It might be helpful if you attach a screenshot of your monitor when that popup appears.

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

In C and C++ languages array subscripts begin with 0, not 1. So line 24 should be t[0] = ... . Other lines in your program need to be adjusted accordingly, such as use t[0] and t[1].

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

The 2010 Winter Olympics in Canada. Started about 8:00 p.m. where I live.

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

You have to specify the full path to the new folder, otherwise it will just get created in the current working directory. sprintf(dirname,"/usr/include/somewhere/test%d",i);

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

>>(I will also post this thread at c++ area, hope you don´t mind )
Yes we do so don't do that. Pick a forum and stick with it.

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

I beg to differ. You get what they want to send you. You do get the option of a few Dell-approved upgrades -- like a couple graphic cards, maybe a couple disk drives -- but very limited real options. And you have no choice on some software like AOL and other trial software cluttering up your drive that no sensible person would want.

And you do NOT get OS install disks. You usually get a directory on the HD (taking up space you should be able to use) which is useless if the disk crashes. But you get charged for the entire OS...

That's pretty much the same with all pre-built computers. I bought a HP Pavillion some time ago and it was like that too. As for disks -- they don't give them to you because you can create your own, at least I was (and did) do that. It took three DVDs and will restore the computer back to factory settings.

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

San Francisco is "overseas" ??? OMG! Don't be surprised if you see a lot of men holding hands with other men in that city because it's one of the biggest gay cities in the USA. In 6 weeks it will be sprint time there so the weather should be pretty nice. As for tourist attractions -- I live a little over 2,000 miles from SF so I don't get there very often.

If you have time you might want to drive 55 miles to Fairfield, CA and tour the JellyBelly candy factory. Its pretty interesting.

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

>>Im using vs 2010 beta 2,
Well it is in beta and probably still has a few bugs. Compile with 2008 and see if that problem still persists.