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

What part of the instructions do you not understand? Post what you have attempted to do so far.

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

line 13: you are incrementing i too soon which is causing theThreads[0] to be an uninitialized variable. Move that line down to line 19.

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

In that case you need to learn to crawl before attempting to run in the Olympics. Learn the c++ language from the beginning. Its not something you can learn in an hour or two -- probably takes several months to learn just the basics well depending on how fast you learn and how much time you are willing to put into it.

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

You have to create a Windows Forms project, not a console project, in order to use System::Forms.

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

Now tell us the file and error message(s) you are concerned about.

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

create an array of HANDLE objects so that you can put the code in a loop.

const int MaxThreads = 20;
HANDLE hThreads[MaxThreads];

for(int i = 0; i < MaxThreads; i++)
   hThreads[i] = (HANDLE)_beginthread(TheThread, 0, NULL);

...

for(int i = 0; i < MaxThreads; i++)
   TerminateThread(hThreads[i],0);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

reading date/time is simple -- just use the functions in time.h

time() returns the current date/time in seconds since 1 Jan 1970. Then if you want to know the month, day and year you need to call localtim(), which returns a structure with that info.

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

Post current CLR/C++ files so that we can see what you have done.

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

Yes, System::Windows. You need to start learning how to google for those things.

And what is that "= !" at the end of line 9???

I think what line 9 is trying to ask is if the console window title is the same as Current process name.

if( System::Windows::Forms::Application::ExecutablePath == Console::Title)

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

According to this, ExecutablePath is a property that returns String^ "The path and executable name for the executable file that started the application". So adding "::Equals" after it doesn't make any sense (line 9 of the code you posted).

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

If you want to convert C# to anything then convert it to CLR/C++ which is managed c++ and a very close cousin of C#. c++ itself knows nothing about System.

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

You should leave random_char as int because rand() will return values that overflow (dont fit) char.

Here is a hint how to generate a random number between 'a' and 'z'. Note that any standrd ascii chart will tell you the decimal values of characters.

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

function LoadUsers() must allocate space for each of the character arrays in the users array. All it is currently doing is using the same std::string over and over again, each time destroying the value of the previous time.

Two fixes:
1. re-declare char* users[100] as vector<string> users.

or
2. replace line 43 >>users[counter] = line.c_str()
with this
users[counter] = strdup(line.c_str());

strdup() does two things:
users[counter] = malloc(length+1);
strcpy(users[counter], line.c_str());

If you opt for option 2 then you need to free() each of those strings when finished with them.

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

@Red: you posted the correct solution to the wrong problem.The solution to the problem does not involve swapping the value of any variables.

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

Just make sure that all the functions in the DLL implementation code are exported. You can export entire c++ classes without exporting each individual method of the class.

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

There are at least a couple ways to do it. One is using <map> class and the other is to use an array.

To use an array: create an int array of 255 elements, one for each possible char in the ascii character set. I know that's too many for the characters that will appear in a file but it makes the calculations easier and quicker. Next just increment the element of that array that corresponds to the character read from thje file.

Example:

int counts[255] = {0}; // initialize array with all 0s
char c = 'A'; // a character read from the file
counts[c]++; // increment

After you have finished with all the characters, you can print out a frequency count in alphabetical order by printing all the elements of the array that have a value greater than 0.

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

Or just something simple like this: Note that vectors and swapping are not needed.

For each line in the input file
    Read a line into variables a, b and c
    print variables c, b and a
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sure -- here's one. If you are asking me to do your homework for you then you can forget it.

#include <iostream>
using std::cout;
using std::cin;

int main()
{
  // pur your code here
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read three integers at a time then print them back out in reverse order.

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

Does the program run ok in release mode on your computer?

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

You can't just put the class in the dll without the implementing code to go along with it. Also templates can't be in a DLL and expected to be used in the application program -- it won't work because the compiler doesn't know the data type until the application program that uses it is compiled. Put templates only in header files.

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

If you want to return more than one object then pass them by address as parameters to the function. Note that all vectors should be passed by reference instead of by value to keep the compiler from generating the code needed to duplicate them.

void Util_RAzEl_to_ENU(vector<double>& range, vector<double>& az, vector<double>& el, vector<double>& ENU, vector<double>& return1, vector<double>& return2, vector<double>& return3)
{

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

If you want a class method to be inline then just code it directly in the class declaration. The inline keyword is unnecessary here.

class SomeApp
{
private:
SomeApp()
{
}
public:
 returnType_t SomeState()
 {
    // code here
      return 0;
 }

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

replace fread() with fgetc(). Of course you will have to deleted and rewrite eveything inside that while loop.

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

What compiler are you using? If you don't have the *.lib then you have to call LoadLibrary() and GetProcAddress() for each of the functions. But before you make any drastic changes to your code check the DLL project to see why the compiler didn't create the *.lib. It might because you didn't export any of the symbols from the DLL. google for __dllspec(__dllexport ) for examples how to do that.

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

The second code snippet I posted shows how to convert the three vectors into a single array of doubles.

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

>>ok how many numbers should be initialized from the user?
According to the instructions you posted -- none of them. Just create an array of 10 elements and initialize them with the first 10 Armstrong numbers. No keyboard entries needed. You are trying to make this more difficult than it really is.

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

I'll bite -- after you deposit that money in my PayPal account :)

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

since vectors are arrays why would you want to do that? You could create a vector of vectors

vector< vector<double> > RAzE1;
RaZe1.push_back(range);
RaZe1.push_back(az);
RaZe1.push_back(el);

Of course that won't work if you want to pass the array to a function that expects double[]

Here is an exmaple

#include <vector>
#include <algorithm>
using std::vector;
using std::copy;
using std::cout;

void foo(double a[], size_t size)
{
    for(size_t i = 0; i < size; i++)
        cout << a[i] << '\n';
}

int main()
{
   vector<double> d1,d2,d3;
   vector< vector<double>> t1;
   double d0[255] = {0};
   for(int i = 0; i < 5; i++)
    d1.push_back(i*1.0);
   for(int i = 0; i < 10; i++)
    d2.push_back(i*2.0);
   for(int i = 0; i < 15; i++)
    d2.push_back(i*3.0);
   t1.push_back(d1);
   t1.push_back(d2);
   t1.push_back(d3);
   copy(d1.begin(), d1.end(), d0);
   copy(d2.begin(),d2.end(), &d0[d1.size()]);
   copy(d3.begin(),d3.end(), &d0[d1.size()+d2.size()]);
   foo(d0, d1.size()+d2.size()+d3.size());
   std::cin.get();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'll continue my anti-sigspammer campaign, because I think it's starting to work :)

You must be yelling pretty loudly because I think you are being heard all the way over to PFO. I noticed the some spammers there are creating just one thread and posting about 20-30 spam messages to it. Makes it easy for me to ban them and delete their spam :)

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

deleted lines 5 and 9 because they serve no purpose and are probably screwing up the rest of your program.

Also, make sure you close both files before leaving that if clause.

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

This is an armstrong nuumber You will even find example programs how to compute them.

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

None. Maybe you should volunteer to teach or tutor that course.

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

Welcome to DaniWeb.

For those readers who are not from USA, he is from the state of Alabama, sothern part of USA.

As for reputation points -- see those up and down arrows to the right of each post (except your own)? Just click one of them (up is positive and down is negative)

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

If you hurry up you still have time to add code tags to your post so that people can read the code better. Just hit the Edit button and add this

[code]

// put your code here

[/code]

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

mine is to stay alive long enough to see 2012

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

how to use:

1. call time() to get current date/time as number of seconds since 1 Jan 1970.

2. call localtime() to get struct tm pointer. If you want GMT them call gmtime() instead of localtime()

3. Use sprintf() or strftime() to convert the struct tm to a string in any format you want.

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

They are part of the win32 api functions. Just include windows.h. google for those functions and you will find lots of examples.

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

>>Wish 2012 is not the end...
Not likely. But I read a couple days ago in a tabloid that the world is coming to an end in Sep 2011. The person to said that also said she was not going to quit her current job. :)

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

I put it at the top of the *.h file

#pragma once
#include "Window2.h"
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't just add text to the beginning of a file. You have to completely rewrite the file to do that. First, open a new file, write the new text to it, then copy the old file to the end of the new file. Next, delete the original file then rename the new file to the same name as the old file.

If the file is small enough you can just read the entire file into memory, then rewite it with the new informatin followed by the olf information.


How to get a list of all the files in a folder will depend on the operating system. MS-Windows -- call FindFirstFile() and FindNextFile(). *nix call opendir() and readdir(). After that, call rename() for each file. You could just rename the files as they are retrieved from the previous two function calls if you want to do it that way.

[edit]Also as Walt ^^^ said :)

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

As I understand it n is the number of rows you have to type, the number of characters on each row can be any random value -- the end of a row is when you press the <Enter> key.

char **read(int n)
{
   char** array = new char*[n];

   ...
   return array;
}

To display the chararacters backwards just display them in reverse order -- by that I mean to start at the end of a line and display the charcters one at a time from the back to the front.

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

Did you add #include "Window2.h" at the top of that file? I just compiled the code you posted and did not get any erors or warnings, and it ran just as I expected it to run.

TSims11 commented: He pointed out something I was too dumb to figure out. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well there you go. You are trying to drive on an interstate, freeway or autobahn with a Model T car built in 1910. You are using a 16-bit compiler that has very very limited memory and stack space. Sorry, but there is nothing you can do to fix your problem without switching to a modern 32-bit compiler or reducing the size of those arrays.

jonsca commented: Yes! +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post an example of what you are talking about. It might mean the function returns a 2d array of some sort. It could also mean that its a pointer to a function. Never know until you tell us more.

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

The maximum value of register ax (and other similar 16-bit registers) is 255. Any register can be treated as either signed or unsigned. So 255 is the maximum of unsigned while 126 is the maximum signed.

Registers do not contain instructions -- only data. mov, jmp, cmp, etc are instructions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
struct record
{
   char name[80];
   // blabla
};

int main()
{
   struct record[255]; // creates an array of 255 record structures

   // copy name to the first structure in the array
   strcpy(record[0].name,"John Smith");
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I didn't realize there was that option -- I normally just remove the file from the project.

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

>>PS: I'm an ameture programmer. I'm not in college. I'm a high school seinor. I was just asking for help, not for you guys to do it for me.

If you want to learn to program then you have to learn to read, comprehend, and follow instructions. Both Narue and I have offered to help you but you have so far failed to provide the information we need to do so.

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

You did not make the changes I suggested. You forgot to add the ^ in the declaration of W2. Window2^ W2; Just like c++ and C W2 has to be a pointer. Pointers in CLI are designated with ^ instead of *.