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

tchar.h contains macros that can be used to treat standard c functions as either ascii or unicode, depending on how the program is written. If you replace strncpy() with _tscncpy() it will compile correctly either way. Read that article carefully and it will explain why, and give you an example. There are links at the bottom to other string manipulation functions.

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

The code is incorrect and the compiler will puke out errors at you. All parameters must be passed by reference. method(&a, &b, &c);

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

what is it that you want to do with strings? There's possibly an equivalent in c++.

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

It doesn't. And you can't.

>>create an application in real mode that uses the flags to store the results of calculations and other stuff.
As I said before, that is a mis-use of the flags. Even if you could change them they won't stay that way very long because the flags are changed when certain operations are performed. The only flag I can think of that you can change yourself is the direction flag using cli instruction.

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

Lets assume all you need are 8 or fewer flags which can be store in one byte of data

flags db 0 ; allocate memory for the 8 flags

; set the 2d bit 
mov al,flags
or al,00000010h
mov flags,al
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't want to screw around with eflags like that -- you are misusing that flag. What you want to do is declare a variable to hold all the bit-mapped flags then you can set and clear the individual bits to your heart's content.

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

The function you are calling is UNICODE function. LPWSTR is a pointer to a unicode string, not an ascii string. You need to declare the string like this: wchar_t ConvertTime[9]; , or if you want to compile the program as either ascii or unicode then use the macro TCHAR: TCHAR ConvertTime[9]; and include <tchar.h> header file.

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

What is the significance of '\0'? That byte may appear in binary files hundreds or thousands of times, but will rarely, if ever, appear in text files.

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

What is that loop beginning on line 20 trying to accomplish? Read a file one byte at a time until EOF? ifstream.read() will return NULL when EOF is reached, so all you need to do is this:

char byt; // no need for a pointer here
while( inFileDrs.read(&byt, 1) )
{

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

You need to include <string> header file.

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

Here is an example where Form1 copies the text from Form2 after Form2 closes. In Form2.h I added a public method that return the String from its textBox1 text control. Similar technique can be used for all of the controls on Form2.

Form2.h

public:
        String^ GetTextBoxString() { return textBox1->Text; }

Form1.h This method is envoked when a button control is clicked.

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 Form2^ f2 = gcnew Form2;
                 this->Hide();
                 f2->ShowDialog();
                 this->textBox1->Text = f2->GetTextBoxString();
                 this->Show();
             }
    };
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not sure what your asking. You have Form1 that invokes Form2 and you want Form2 to return something to Form1?

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

A lot of people will disagree with you. HappyGeek wouldn't be caught dead without Chrome (he has stated that on more than one occasion).

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

I don't use a laptop, so I can't help you with that. Suggest you start a new thread here to begin discussion of your problem.

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

What browser are you using? try Google Chrome and see if that fixes the problem because its faster than IE. Don't know about FF because I have not used it for a couple years now.

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

First program:
line 18: fread() doesn't work very well with stdin because it doesn't terminate the input with the string null terminator. That's why everyone calls fgets().

Since you are writing a c++ program you can do away with fgets() and fread(), just use the functions in std::cin and std::string std::getline(newBuffer, std::cin); line 26: you can only call free() on pointers that have been allocated with malloc(). Since Buffer has not been allocated with malloc() the free() call on line 26 will fail. Your compiler should have complained about that, assuming you attempted to compile that code at all.

line 28: you are assuming that the find() on the previous line succeeded. What will that do if it failed? You need to add some error checking here.

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

You are reading the wrong tutotorial -- that was written for MAC, not MS-Windows. It's quite easy with VC++ 2010 Express or Code::Blocks, both compilers have start-up templates that generate appropriate code for you, then all you have to do is add your own code that you want to export from the DLLs.

Ditch that old, ancient Dev-C++ compiler that hasn't been updated in a couple centuries and get either of the above two mentioned compilers.

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

If you look in logmsgs.h you will probably find that function defined there. You can not put executable code in header files because it results in the error message that you got. Put just the function prototype in the header file and the actual function in one of the *.cpp files.

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

Put code guards in timers.h fixed the problem for me. Note the preprocessor directives at the top and bottom of the file. This prevents the preprocessor from parsing the file more than once in the same *.cpp file.

#ifndef _TIMERS_H
#define _TIMERS_H
#include "includes.h"


class servtime
{
public:
	int sec()
	{
		int sec;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		sec=timeinfo->tm_sec;
		return sec;
	}
	int mint()
	{
		int min;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		min=timeinfo->tm_min;
		return min;
	}
	int hour()
	{
		int hour;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		hour=timeinfo->tm_hour;
		return hour;
	}
	int day()
	{
		int day;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		day=timeinfo->tm_mday;
		return day;
	}
	int month()
	{
		const int MONTHS[]={1,2,3,4,5,6,7,8,9,10,11,12};
		int month;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		month=timeinfo->tm_mon;
		return MONTHS[month];
	}
	int years()
	{
		int year;
		time_t rawtime;
		tm * timeinfo;
		time(&rawtime);
		timeinfo=localtime(&rawtime);
		year=timeinfo->tm_year;
		return (1900+year);
	}
};
#endif
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Functions should never ever be in header files -- only function prototypes. The reason is if you have that header file in two or more *.cpp files then attempt to link those *.cpp files together you will get duplicate declaration errors.

Here is how to correct that problem
count.h

extern int count(int );

main.cpp. Notice how I made a few changes to your program

// Always put the include headers at
// the top of the program, like this:
#include <iostream>
#include "count.h"
using namespace std;

int count (int x) {
	x = x + 1;
	return x;
}

int main () 
{

   int num;
   num = 24;
   std::cout << num << std::endl;
   num = count (num); // you have to capture the return value of count()
   std::cout << num << std::endl;
   std::cin.get();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you hury up you can correect the code tags.

[code=cplusplus]

Notice no spaces and its cplusplus not c++


Are you talking about converting UNICODE wchar_t* to char*? Here is a thread that shows one way to do it.

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

You are of course right if all you want to find out if there were any non-digit characters entered and not interested in what the characters actually were.

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

The easiest way to validate addBalance is to get user input as a string instead of int. Then you can check each character of the string for valid digits.

isalpha() doesn't work for you because the parameter to isalpha() is a single character, not an integer.

Example:

std::string input;
cout << " You can now add some fund to your account. How much do you want to add?\n" ;
while(1)
{
   getline(cin, input);
   // check input for non-digits
   bool valid = true;
   for(size_t i = 0; i < input.size() && valid == true; i++)
   {
      if( !isdigit(input[i]))
      {
        cout << "Error\n";
        valid = false;
      }
   }
   if( valid )
      break; // exit infinite loop
}
int addBalance;
// convert from string to int
stringstream str(input);
str >> addBalance;

[edit] Didn't see Narue's solution when I posted this ^^^

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

Only the operating system can determine where a program is loaded because there are probably other programs in memory whose address may conflict the the one you specify. The program loader reads the program into memory, finds out where to store it, then resolves all program addresses to actual physical address, such as resolves the addresses of all call statements. Even MS-DOS 6.X and earlier work that way because of TSRs (Terminate and Stay Resident, which are the grandfather of modern device drivers).

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

0x08 is a backspace
0x6d is the letter 'm'

Don't you want something like
if( Char::IsDigit(e->KeyChar) || e->KeyChar == 0x08 || e->KeyChar == '-')

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

Would you care to explain a little more what the problem is? You posted several while loops -- which one(s) is giving you the problem?

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

Your suggestion is no different than Narue's. CreateFile() with CREATE_NEW will fail if the file already exists. Same, but opposite, behavior that Narue suggested.

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

Express version does not support that. You have to buy either te standard or better version.

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

"setup and deployment"??? AFAIK the Express version does not have such an option.

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

Reading the input stream is the only standard way to do it. That means you have to dynamically expand the input buffer with realloc() while reading the input stream.

vedro-compota commented: +++++++++ +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you learn to read the previous comments

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

Your program doesn't work because it is destroying the ch1 pointer on each loop iteration. You can't increment ch1, just leave it along after the initial allocation with malloc(). Use a different pointer or integer.

Another problem is that your program is very very slooooow -- malloc() and realloc() are rather time consuming, so instead of allocating just one character at at time you should allocate a block of characters, then when the block is filled up you should call realloc() to increase the block

#define BLOCK_SIZE 80
int block_size = 0;
int current_spot = 0;
char* c1 = 0;
char c;

while( (c = getchar()) != EOF )
{
   if( block_size == current_spot)
   {
       c1 = realloc(c1, block_size + BLOCK_SIZE); 
       block_size += BLOCK_SIZE;
   }
   c1[current_spot] = c;
   ++current_spot;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Post your code or do you think we are mind readers?

malloc() and calloc() work perfectly -- its your code that doesn't work for some unknown reason.

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

make that check at line 40 of the code snippet you posted. If you don't want to process any subdirectories at all then delete lines 37-43, just leaving an empty if statement.

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

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

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

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

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

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 :)