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

>>The list I have created, is it a linked list?
No. Is an array, not a linked list.

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

I see another new stat too -- number of activity points. I have never noticed that before, and assume it's reset to 0 each day. Might be interesting to have a link that would show a graph of total activity points for each day over the past month or so. Or maybe totals by week/month over a longer time period.

Might be interesting to see some site-wide averages -- average number of posts per day for members who have made one or more posts during the past 24 hours.

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

malloc(), calloc() and realloc() are C functions to allocate memory, although they can be used in C++ it is preferable to use the new operator. The two (malloc() and new) should not be used together in the same program.

resize() is NOT a C or C++ function, but is often included in the STL container classes, such as vector and list.

new has to be used to dynamically allocate c++ classes because the new operator will call the class constructor -- malloc() will not do that because it is a C function which was carried over to c++ when c++ was invented.

>>Are malloc() and realloc() frequently used?
Not in c++ programs written by professional programmers. You might see students using them for academic purposes.

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

Look at the information just above the Message edit box. It has a link to mark the thread as solved.

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

what errors are you getting?

In matrix_add() function you are trying to use an uninitialized pointer m.mat. It has to be allocated memory before setting the array elements in those loops. Move the two lines m.rows = and m.cols = up above the two loops then allocate memory for m.mat.

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

The Item array you posted is a static array, not a dynamic array. To convert it to a dynamic array you have to make it a pointer and then use new to allocate the array siz

Item* list;
list = new Item[maxnumber];

After that you can put maxnumber number of items in the array. If you need to make the array even bigger you have to reallocate and copy

// allocate new temp array
int newsize = maxnumber + 10; // or whatever value you want to use here
Item* newlist = new Item[newsize];
// copy items from old array to new array
for(int i = 0; i < maxnumber; i++)
   newlist[i] = list[i];
// destroy old array
delete[] list;
// set old array to the new array pointer
list = newlist;
maxnumber = nwsize;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There is no such thing as c++ windows class in windows.h -- its all pure C code. There have probbly been in excess of 1,000 Microsoft programmers who wrote those win32 api functions.

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

I hate the Office 2007 menu ribbon -- it is really awful and difficult to navigate such simple things as Open, Save, and Edit. Anyone know if there is a way to make the menus look like older versions of Office?

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

converting char[4] to int is simple assignment int x = *(int *)buffer; , assuming that buffer contains the binary representation of the int.

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

Yes of course its possible.

>>Can we treat these files as if they all are readable in binary mode?
Yes, but you may not have permissions to do that. That is an operating systems problem, not C or C++.

How to actually read those files is a different matter altogether. Each file type has its own file format so before you can expect to make anything useful of the data in an *.mp3 file you have to know how it was written. Search google for "mp3 file format". Same with other file types.

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

Join their mailing list and ask them. Nothing like getting the info straight from the horse's mouth (American joke - sorry if others don't understand it.)

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

go to amazon.com and search for "web development" books. Also look here for tutorials

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

Since you didn't bother to use code tags I'm not going to bother reading it very well. The problem is most likely using calloc() instead of realloc() to increase or decrease the size of the buffer.

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

Now how in the world do you expect to decrypt a file without reading it?? Just read the file, decrypt it and save it in memory. I don't see why you need a temp file to do that.

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

It's a series about Superman when he was a teenager. The problem with such a series is that the actors eventually grow older and no longer believable for someone that age, so either recast the part as in Dr. Who or cancel the series.

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

I didn't compile the code I posted -- should have included <iostream> and using std::cout statememt.

The code I posted is just one example of how to write the csv file. Using a vector you would want write it in a loop, remembering that numeric data is not enclosed in quotes.

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

What do you mean you want to change the stream to something else? What do you want to change it to?

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

Of course -- I thought everyone knew how to do that. Just get yourself one of the many free compilers and write the code. As for language -- just take a look at all the languages available in the Software Development menu. Many of them will create a *.exe but some won't because they are interpreted languages.

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

>>any program written for Windows is inherently not free
Commercial software yes, otherwise there are thousands of freeware programs for MS-Windows. OpenGL and OpenOffice are just two of them.

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

You can't compare char* with an it -- just won't work.

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

>>By the way, I find the arguments about "which is better, WinZIP and WinRAR?"

I don't think we were debating that -- just whether WinRAR was free or not. As for which of the two is best, I haven't the slightest idea because I never used WinRAR. All I care about is getting the *.zip files decompressed and could care less which program does a better job of it.

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

By itself it means absolutely nothing. In 16-bit compilers such as Turbo C it is sometimes necessary to hardcode memory addresses, such as the screen on MS-DOS is located at 0x8000 (or something like that). So it might be necessary to cast a pointer to that address char* screen = (void*)0x8000; Such addresses is not possible with 32 and 64 bit compilers.

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

The only time \\ is needed is for string literals, like one you posted because the compiler has to interpret each of the characters in the string literal. When the path is typed in from the keyboard of read from a file the \ does not have to be escaped because the compiler will never see it. So typing the path in an edit control then coping it to a CString object can be done without escape characters.

Jsplinter commented: I see, thank you +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To convert a character from lower to upper case

char c = 'A';
cout << tolower(c);

and to convert from lower to upper, replace tolowe() with toupper(). Subtracting 32 from the character can easily lead to disaster.

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

>>Thus to convert a lowercase to an uppercase letter, subtract 32 from it.

Wrong -- that could be disasterous if done dimwittedly. The macro toupper() and tolower() should be used to convert a character from upper to lower, or vice versa because it is part of the C and C++ standards, and is portable across all compilers and operating systems.

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

Do you know how to open a file and write to it? You can put the " character in the file by using the escape sequence \".

#include <fstream>
using std::ofstream;

int main()
{
   char *string1[] = {"a1","a2","a3","a4"};
   char *string2[] = {"b1","b2","b3","b4"};

   ofstream out("filename.csv");
   for(int i = 0; i < 4; i++)
   {
      cout << "\"" << string1[i] << "\"";
      if( < 3)
        cout <<", ";
   }
   cout << "\n";
   for(int i = 0; i < 4; i++)
   {
      cout << "\"" << string2[i] << "\"";
      if( < 3)
        cout <<", ";
   }
}

You can shorten the code a bit by putting the loop in a function of its own and passing to it the string to be sent to the file.

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

A technique I have used is to use another int array that represents the index values of the original array or vector. Sort the vector as normal but instead of swapping vector values you would swap the index array values. You could use std::sort() for this if sort the index array and write the comparison function to compare strings in the vector

vector<string> myvector;
bool compare(int& a1, int& a2)
{
   return myvector[a1] < myvector[a2];
}

int main()
{
   vector<int> index;
   index.resize(10);
   for(int i = 0; i < 10; i++)
       index[i] = i;
   std::sort(index.begin(),index.end(),compare);
   // display the sorted vector
   for(int i = 0; i < 10; i++)
     cout << myvector[index[i]] << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you have not already seen this wiki article then you might want to read it and follow some of the links it contains. Might be useful to you.

>>and neither am i running the app on a pc or mac

Oh I see. In that case Winzip or any other Windows program prbably will not help you.

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

Should be not very complicated. Just read the files in a loop

#include <string>
#include <fstream>
#include <sstream>

int main()
{
   std::ifstream in;
   for(int i = 1;  <= 100; i++)
   {
       std::stringstream s;
       s << i;
       std::string filename = "a.out";
       filename += s.str();
       in.open(filename.c_str());
       if( in.is_open() )
       {
          std::string line;
          while( std::getline(in,line) )
          {
             // do stuff here
          }
          in.close();
          in.clear(); // clear eof errors
       }
     }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Never heard of it -- but it's not free either, which makes it just a competitor of WinZip

From their download site

You can try WinRAR before buy, its trial version is available

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

>>Personnel number (integer greater than 0, enter 0 or a negative value indicates that data entry is over.)

That tells you to create a loop that runs until you enter a value <= 0

int PersonnelNumber = 1;
while( PersonnelNumber > 0)
{
   // do things here

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

zip and rar files are compressed files which can not be easily read by any program other than the one that wrote them. If you want them uncompressed you would be better off just calling winzip to decompress them for you. WinZip is not free -- only trial version is free for a little while.

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

Use <map> and you won't have to be concerned about duplicates.

Or sort the vector first to make it easier to find duplicates.

The operator< on line 20 will not work correctly because it will never reach the two lines that test for y (lines 24, 25 and 26 are unreachable).

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

The error message means that selectManagrTask() is not a member of that class. Check the spelling of that function in the class declaration.

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

First -- thanks for using code tags correctly on your first post here.

Nice code, but why did you post it?

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

Nice instructions -- but what do you want to know about them? I hope you don't want anyone to write the program for you because we don't do that.

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

>> how can i delete the previous lines in the file and write a new lines

You will have to rewrite the entire file. It's not possible to insert new lines somewhere in the middle of a text file without rewriting it. You already have the vector, so just interate through it and write the strings to the file.

As for your other question -- can't say what's wrong from the code snippet you posted. Will need to see the entire program.

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

Look at the date of her post -- "tonight's episode" was aired about 4 years ago :)

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

In alloc_vec(), new_vector_ptr is just an uninitialized and unallocated pointer that points to some random memory location. You have to allocate memory for it before it can be used for anything.

Vector *alloc_vec(void)
{
Vector *vector_ptr = new Vector; // <<<<<< Here
vector_ptr->size = 0;
vector_ptr->array = NULL;
vector_ptr->array = new Elem[vector_ptr->size]; 

return vector_ptr;
}

in delte_vector() use delete, not delete[] because vector_ptr is not an array.

void dealloc_vec(Vector * vector_ptr)
{
delete vector_ptr; // When done, free memory pointed to by vector_ptr
vector_ptr = NULL;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First you have to declare an object of type FLATMATE and then push it onto the vector

FLATMATE fl("John");
myvector.push_back(fl);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Instead of just bitching about what I posted why don't you try actually reading and comprehending it. I told you several hours ago what the problem was with your code. It's not my fault you are apparently too dense to understand my first post. Learn to use your head for something other than a hat rack.

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

Please STOP putting your comments in code tags -- code tags are just for c++ code, not the comments you want to make.

winzip can not open the zip file you posted.

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

>>According to my book/teacher (and in the past my compiler), a single-letter string can be represented by the ASCII dec number in single quotes

Either you mis-understood your teacher or your teacher needs to quit teaching and take up basket weaving. The decimal value of ascii codes are NOT put in quote

>>It actually gives me an error if I put what you suggested
Post what you tried because it seems to work for everyone else in this world (roughly 4 billion people) but not for you ;)

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

sorted lists means the items are in alphabetical or numeric order, unsorted means they are in just some random order.

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

In the example line you posted, position 13 is the letter 'E', (in MET), not 'N'. And pos 24 is '1' (in 916).

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

In USA you can copyright software simply by putting copyright statement at the top of the source code (in comments of course). I don't know a thing about India.

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

>>if (choice3=='89')

'89' is not 'Y'. There is no such thing as 89 within single quotes. Your compiler should have given you an error or warning on that, which I have to assume you ignored. if(choice3 == 'Y') is what you want. But what if you type 'y' instead of 'Y'?

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

namespaces will complicate the name mangling. How names are mangled is compiler dependent -- there is no standard way that they do it. You will want to have your c++ compiler generate a map file which will contain the mangled names.

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

you mean it won't compile? What compiler and operating system?

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

The code snippets you see in these forums is not necessarily intended for new programmers.

>>and learn to do proper documentation with your codes!
I agree that most of the programs in these forums lack adequate comments that explain what the functions do. But the code is written by students, not professionals.