mitrmkar 1,056 Posting Virtuoso

Hmm, you have made a major (negative) change to the ReadFromFile() ...
I try to explain ...

bool ReadFromFile(ifstream &inp, string &item, double &cost, int &quantity)
{
    inp >> item;     //<- extract a string from the file
    inp >> cost;     //<- extract a double from the file
    inp >> quantity; //<- extract a int from the file

    return (inp >> item >> cost >> quantity); //<- Do the above three operations again
}

So, you read two sets of items each time in that function, to remedy it you should
have it like

bool ReadFromFile(ifstream &inp, string &item, double &cost, int &quantity)
{
    // extract, string, double and int from the file
    // returning a value which indicates whether all three items were
    // successfully extracted
    return (inp >> item >> cost >> quantity);
}
mitrmkar 1,056 Posting Virtuoso

That didn't quite work as i wanted

Sounds a bit odd, because the (LPCTSTR) cast effectively gives you a 'const char *', hence enabling to output the whole string to the ofstream.

mitrmkar 1,056 Posting Virtuoso

ofstream is unaware of the CString type, you can cast the CString...

ofstream data("...");
data<< (LPCTSTR) str;
mitrmkar 1,056 Posting Virtuoso

>>It is changing the position from which the string should be read but z compare is not successful.

I don't quite understand that, but with regard to the search itself, you are quite close to a solution. However, in order for the binary search to work, the data (your Institute[] array) must be sorted. Maybe that's the basic problem with your attempt i.e. you are searching an unsorted array?

PS. Note also that the string comparison (element==Institute[m]) is case-sensitive i.e. "Abc" != "abc".

mitrmkar 1,056 Posting Virtuoso

The major failure seems to be in the ReadFromFile(), you have a while loop in it, which most certainly should not be there.

I suggest you to radically change the ReadFromFile().

1) make it return a value that indicates whether the read was successful
2) pass the 'item' by reference
3) remove the total_cost and final_cost arguments
4) remove the while() loop

[B]bool[/B] ReadFromFile(ifstream &inp, string [B]&[/B] item, double &cost, int &quantity)
{
    // The following returns true as long as inp is capable of reading in
    // data for all three arguments
    return (bool)(inp >> item >> cost >> quantity);
}

Then, in your main() function you can use the function like

while(ReadFromFile(inp, item, cost, quantity))
{
    CalculateCost(cost, quantity, total_cost, final_cost);
    WritetoFile(out, item, cost, quantity, total_cost);
}

Lastly, I think you should remove the

if(item == " ")

block and the final_cost argument from WritetoFile(), i.e. WritetoFile() would be

void WritetoFile(ofstream &out, string item, double &cost, int &quantity, double &total_cost)
{
    out.setf(ios::right);

    out << setw(15) << item << setw(18) << cost 
          << setw(21) << quantity << setw(24) << total_cost;
}
mitrmkar 1,056 Posting Virtuoso

error
press any button to continue...

So the problem seems to be in opening the file(s) .. delete one of the OpenFiles() calls, i.e. you should do with only a single

OpenFiles(inp, out, "p05.txt", "p05out.txt");

in your program.

mitrmkar 1,056 Posting Virtuoso

You are probably trying to copy memory to a destination which is too small in size.

At the time that assertion fails, you may find the offending piece of code by viewing the call stack.

mitrmkar 1,056 Posting Virtuoso

The output i am getting on the VB interface = ¯õ#;‘ƒ9s„‡Ñ'Ý¢@ýýýýÝ (21 bytes)
What can cause the problem...

There is no terminating null byte in the string, allocate 1 byte more and terminate the string yourself, e.g.

char* plaintext = new char[size + 1];
plaintext[size] = 0;
kartouss commented: Very helpful +1
mitrmkar 1,056 Posting Virtuoso

I can try to explain it a little better if that is the case

A good idea, so please do that ...

mitrmkar 1,056 Posting Virtuoso

That will not work because the elements in 's' are vector<string> vectors themselves,
ostream operator << has no support for that kind of thing by default.
If you really want to pass e.g. a vector<string> to cout, you can write;

ostream & operator <<(ostream & o, const vector<string> & v)
{
	for(vector<string>::const_iterator it = v.begin(); it != v.end(); ++ it)
	{
		o << *it;
	}

	return o;
}
mitrmkar 1,056 Posting Virtuoso

Change

char sk[4][4];

to

char sk[16];
mitrmkar 1,056 Posting Virtuoso

The linker complains because it cannot find definition for
static const byte q[2][256];
static const word32 mds[4][256];

Try downloading the complete crypto++ library in one .zip file from e.g.
http://gd.tuwien.ac.at/privacy/crypto/libs/cryptlib/cryptlib.v42.html#download

mitrmkar 1,056 Posting Virtuoso

void binary(int) does not return anything, hence you cannot use it like you have done.
Without modifying the binary() function, you could use it like ...

case 'B':
case 'b':
cout << "\n ANSWER = "; binary (firstNumber);
break;
mitrmkar 1,056 Posting Virtuoso

I need to get a text file and insert each character into a seperate node in a linked list

You don't need the dnode construct actually, instead you can simply use std::list<char> myList;

#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <list>

using namespace std;

void loadFile(list<char> &myList, const char *file);

int main(int argc, char *argv[])
{
   if (argc != 2) {
      cout << "Syntax : File Error\n";
      return 0;
   }

   list<char> myList;

   loadFile(myList, argv[1]);

   // Use an iterator to display the content
   for(list<char>::iterator it = myList.begin(); it != myList.end(); ++ it)
   {
	   cout << *it;
   }
   return 0;
}

void loadFile(list<char> &myList, const char *file)
{
   ifstream fin;
   
   fin.open(file);
   if (!fin) {
      cout << "Unable to read from " << file << "\n";
      exit(0);
   }
   
  char aChar;
  fin >> noskipws;  // do not skip whitespace

  while (fin >> aChar)   // Reads one char at a time
	  myList.push_back (aChar);

  fin.close();
}
mitrmkar 1,056 Posting Virtuoso

Implement the timer proc outside the CServiceModule class.
I.e. you will have

VOID CALLBACK ::TimerAPCProc(...)

instead of

VOID CALLBACK CServiceModule::TimerAPCProc(...)
mitrmkar 1,056 Posting Virtuoso

The code looks strange (I'm in a hurry now and can't explain in details),
anyway try something like;

form2 frm;
frm.ShowDialog();
MessageBox:: Show(frm.textBox1->Text);
mitrmkar 1,056 Posting Virtuoso

niek_e got there first ...

mitrmkar 1,056 Posting Virtuoso

With regard to the subject, NT and XP are quite alike.

mitrmkar 1,056 Posting Virtuoso

Sorry to say, but you seem to have the very basics of C++ pretty much mixed up.
I'd really suggest you to pick up your text book and take your time to go through it from the beginning.

mitrmkar 1,056 Posting Virtuoso

having a little bit of a problem running the output file

Could you be more specific about the problem(s)?

mitrmkar 1,056 Posting Virtuoso

See "Port I/O with inp() and outp() Fails on Windows NT"
http://support.microsoft.com/kb/112298

You may find this interesting
http://www.beyondlogic.org/porttalk/porttalk.htm

mitrmkar 1,056 Posting Virtuoso

Try searching daniweb for "prime numbers", there ought to be many matches ...

mitrmkar 1,056 Posting Virtuoso
mitrmkar 1,056 Posting Virtuoso

Any reccomendations of what to add?

Hmm, how about conversions, like from hex to dec/bin/oct and vice versa?

mitrmkar 1,056 Posting Virtuoso

Just a note, you should hide the constructors so that there is no possibility to have more than one instance of the class (i.e. make it truly singleton).

Then, an alternative to get/create the instance is;

myClass & myClass::getInstance()
{
    // The one and only instance ever created
    static myClass singleton;
    return singleton
}
mitrmkar 1,056 Posting Virtuoso

Add one 'else' to glue the if statements together

if( boolSqrt == 'Y' || boolSqrt == 'y' )
{
    <snip>
}
[B]else[/B] if( boolSqrt == 'N' || boolSqrt == 'n' )
{
    <snip>
}
else
	cout << "\n WRONG DECISION.";
mitrmkar 1,056 Posting Virtuoso

When i choose to use square root, i input the number then it outputs my answer but after it it prints the case default?

It appears that it would print 'WRONG DECISION.' when using square root, because
effectively you have the following construct

if( boolSqrt == 'N' || boolSqrt == 'n' )
{
	<snip>
}
else
	cout << "\n WRONG DECISION.";
mitrmkar 1,056 Posting Virtuoso

because I have no idea where the problem is

Here is one link that might get you started
http://www.cprogramming.com/debugging/segfaults.html

mitrmkar 1,056 Posting Virtuoso

Regarding books, one link is ...
http://www.daniweb.com/forums/thread70096.html

mitrmkar 1,056 Posting Virtuoso

If you want to keep using the array 'char s[100]', you can explicitly copy the
ostringstream's content into the array.
I.e ..

strcpy(s, outs.str().c_str());

Or use the >> operator, i.e.

outs >> s;
mitrmkar 1,056 Posting Virtuoso

The following is pretty much like your original construct using an array of ints,
the difference is that the numbers are read from the file instead of the keyboard

const int MAX_NUM = 8;
int sort[MAX_NUM] = {0};
int count = 0;  // Count of numbers in the 'sort' array
ifstream infile("numbers.txt");

// At max, read MAX_NUM numbers into the int array 'sort'
for( ; count < MAX_NUM && infile >> sort[count]; count ++)
{
    cout << sort[count] << "\n";
}
cout << "Read " << count << " numbers ...\n"; // Display the count of numbers read
mitrmkar 1,056 Posting Virtuoso

You can use ifstream for that purpose. Assuming that you have a file named numbers.txt (containing numbers),
you could read it as follows

ifstream infile("numbers.txt");
int nn;
while( infile >> nn )    // Read one number at a time
{
    printf("%d\n", nn);  // Display the number read
}
mitrmkar 1,056 Posting Virtuoso

You cannot do it like that, 'word' is there a pointer to a char.
So, try with an array of chars instead

char word[21] = "";
scanf("%20s",word); // at max, 20 characters get scanned to the 'word'
mitrmkar 1,056 Posting Virtuoso

I suppose you are using the personalAccount somewhere, could you post that code, i.e.
if you have e.g. something like

int main()
{
    personalAccount Account;
     ...
mitrmkar 1,056 Posting Virtuoso

smallest

mitrmkar 1,056 Posting Virtuoso

Like Ancient Dragon already stated ..

Write the program just a little bit at a time so that you don't get overwhelmed by the length of the assignment.

So, try divide and conquer the problem.
It doesn't even have to be solid code but instead you can try and figure it out in pseudo-code first and post it here.

mitrmkar 1,056 Posting Virtuoso

No, you need to get a working understanding of the keyword 'extern' in C/C++.

mitrmkar 1,056 Posting Virtuoso

The problem is that there probably is no definition of the variable muscleTendonLength anywhere (hence the linker really is unable to do its job).
See
http://c-faq.com/decl/decldef.html
and place the definition

dpMuscleTendonLengthStruct* muscleTendonLength;

somewhere suitable in your code. You may also want to initialize the definition of muscleTendonLength to e.g. NULL.

mitrmkar 1,056 Posting Virtuoso

It seems that you are working with an old version (2.0.33) of the library. I did not find any version that would contain the makemsvcimport.bat batch file.

I'd suggest that you download the

http://www.libgd.org/releases/gd-latest-win32.zip

That archive seems to come with a pre-built .lib file + the corresponding .dll, i.e. you don't have to build anything yourself.

mitrmkar 1,056 Posting Virtuoso

Don't i have to include some libraries in the project->link tab for example ?

Yes you have to, you will be using the bgd.lib import library for that purpose. At run-time, your program will then use the bgd.dll.

But first you really have to create the bgd.lib import library. Apparently the
makemsvcimport.bat file is the tool for that. Since you have MSVC installed, your environment variables (hopefully) are already correctly configured, so you should be able to simply just run the makemsvcimport.bat file (I'm not 100% sure though).
Anyway, try it (makemsvcimport.bat) out and see if it succeeds. If not, post more questions here ...

If your compiler is unable to find the "gd.h" header file, configure the MSVC's Tools/Options/Directories/Include files to have the directory where you have the "gd.h" header file.

mitrmkar 1,056 Posting Virtuoso

on linux platform, After sending the signal SIGINT using cntrl+C, the numbers are printed from 1 to 100000. In case I press cntrl+c again during the time my code is executing the for loop for pirnting numbers between 1 and 100000, it doesnt have any effect on the printing.

Are you 100% sure that e.g. "Inside Signal Handler" doesn't get printed the second time at that time?

on windows if i press cntrl+c second time, the Exe stops immediately.

That is because Windows has restored the handler i.e. your handler is not in effect anymore after the initial Ctrl+C got handled.

How call I disable the signal catching second time.

You might re-install the handler inside the handler itself.
However, on Windows you'd probably be better off using SetConsoleCtrlHandler().
http://msdn2.microsoft.com/en-us/library/ms686016.aspx

Note that your handler function's signature
void intr_hdlr(void);
is not correct. You should be able to call signal() without casting the handler argument like you do now.

mitrmkar 1,056 Posting Virtuoso

You need to tell the IDE to link with the Winmm.lib library also, so open
Project/Properties/Configuration Properties/Linker/Input
and append winmm.lib in the Additional Dependencies field.

Also, use the first block of code you've tried, i.e.

PlaySound(TEXT("test.wav"), NULL, SND_ALIAS | SND_APPLICATION);

mitrmkar 1,056 Posting Virtuoso

It is simple to use ...

// Invoke the dialog box...
folderBrowserDialog1->ShowDialog();
// User just closed the dialog ... display whatever was selected ...
System::Windows::Forms::MessageBox::Show(folderBrowserDialog1->SelectedPath);

However, note that it browses for folders (not files)

mitrmkar 1,056 Posting Virtuoso

I think you need to understand what a function is and how to use one, here is a short basic tutorial
http://www.cplusplus.com/doc/tutorial/functions.html
and
http://www.cplusplus.com/doc/tutorial/functions2.html

mitrmkar 1,056 Posting Virtuoso

Try taking a look at here
http://en.csharp-online.net/CheckedListBox
to get an idea about what a multicolumn listbox is.

mitrmkar 1,056 Posting Virtuoso

So, I juz wan to make a simple file browser function to add the "name(string)" of file selected into the combobox.

Then you can probably use the GetOpenFileName function, see
http://msdn2.microsoft.com/en-us/library/ms646927(VS.85).aspx

mitrmkar 1,056 Posting Virtuoso

You haven't removed the file(s) from the project I guess, so select the desired file in the workspace window's file tree and press Delete.

mitrmkar 1,056 Posting Virtuoso

Like vijayan121 already pointed out, you need to use the Show() method instead of the ShowDialog(). So try ...

private: System::Void button2_Click_3(System::Object^  sender, System::EventArgs^  e) 
{
	 this->form22instance.Show();
	 this->form4instance.Show();
}
mitrmkar 1,056 Posting Virtuoso

You already know how to read the file in one char at a time and convert it (to upper case), i.e.

while( (c = infile.get()) > 0 )
{
    outfile << (char)toupper(c);
}

One thing you could do is to write a function which behaves like toupper(), i.e. takes one character as an input and returns the processed character, so you might code yourself an encrypt() function and use it like ...

while( (c = infile.get()) > 0 )
{
    outfile << (char)[B]encrypt[/B](c);
}

And from there on, you'd probably could quickly derive the counterpart decrypt() function.

mitrmkar 1,056 Posting Virtuoso

What do you mean by

load this external exe and display it within that control window