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

what operating system? what compiler? GUI or console? You have left out a lot of info that we need to help you.

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

Nice picture, but why are you posting it?

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

have to see the file. Maybe there is a Ctrl+Z at the end of the first file which makes ifstream think its at end-of-file.

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

I suppose you have already figured out that the error message is coming from line 26 of the code you posted. Find out how _WIN32_WINNT is defined and then define it correctly yourself. (Right-click on the symbol and you will have the option to go to where its defined) Something has probably changed between verion 2005 and 2010. I don't have the ultimate edition, so I can't really help you.

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

Oh nevermind -- my fault.

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

See attached. I got that page by clicking New Posts. It shows a thread has 65 replies, but when I go to that thread it has only 1 reply, from Narue.

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

Which version of vc++ 2010 did you install? Express does not support atl or mfc.

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

It reads gibberish because you failed to validate that the file was opened on line 16, which I can see that it was not. Your compiler should have produced an error message saying the std::stream.open() does not take a std::string object as the first parameter. ifs.open(inputfilename.c_str()); Then check if the file was actually opened. if( !ifs.is_open() )

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

I know someone who gets a pension of some kind from UK and she told me that UK takes some money out of her pension every month to pay for that wedding. I'm rather shocked about that, I would have though the Queen and royal family would have footed the bill not the UK citizens. Maybe Prince William and Kate should have just eloped and saved everyone all that expense. Of course I know they couldn't have done that, but still ....

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

Standard C functions won't work, but One way to do it is to use non-standard conio.h functions. special keys will return one of two values the first time getch() is called, either 0 or 224. The actual key code is returned in the second call to getch() and will be the same number as a normal key. For that reason I just make the code a negative value so that the program knows the difference. Some programmers like to just add 255 to the value returned by the second call to getch().

Of course this will not work if your compiler does not support conio.h. The next best thing would be to use a library such as ncurses, or on MS-Windows use win32 api console functions.

#include <conio.h>

int main()
{
    int key = getch();
    if( key == 0 || key == 224)
    {
        // get special key code and make it negative
        // to distintuish it from normal keys
       key = -getch();
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Which is the best way of earning money

With a HP printer. Of course that will also get you some free room and board at tax payer's expense.

diafol commented: chortle +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you wantch it? I saw the last part, got up at 5:00 a.m. and saw it on CNN. Awesome :) And the gods apparently thought so too because there was lots of sunshine, flag waving, and everything was perfect. I thought 90-year-old Price Phillip looked really really old (of course he is, but that's beside the point). And the Queen appeared to be sleeping during the ceremony.

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

We have a breakroom where I work. Occasionally we will have a charity fund drive where people bake cookies etc and put them on a table in the breakroom with a note to pay 50 cents each. At the end of the day all the food is gone and the jar contains lots of money. (There are about 200 employees). I don't know whether anyone took a cookie without paying for it, but most people did pay.

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

Sound like you are advocating slavery and other good, propertarian values like no vote for women, - and so on.

The amendments are also part of the constitution. So you are wrong about that.

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

So, if you leave comments then you can't reverse it. I guess I misunderstood. I thought I could reverse it with or without comments (and affecting the person's actusl rep).

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

Just how many times do I have to tell you how to do it. I answered that question three days ago in this thread (here)

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

>>how does a lone programmer with a few languages at his disposal make awesome software

Depends on what YOU consider "awsome". Awsome software such as Microsoft Word or Paint, is written by a team of programmers, analysts and graphics designers. And it usually takes years to design, code and test.

Of course you can write your own shareware or freeware programs that do neat little things, but I wouldn't consider them "awsome".

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

But I have not given Dani any rep for a few days now. I know my up vote does not affect actual rep points in this forum, but I should be able to reverse the up vote.

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

75 RPM glass 8 inch records. Crank telephones. No TV. Easter Parades.

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

Post code because I can't see your computer's monitor.

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

Has something changed again? I just upvoted your post but I don't have the option to reverse it.

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

delete lines 114-124 -- foo() was only the name of a fictiuous function, not one that you would actually use.

This is an example of what you want

void displayLeastEaten(double food[][DAYS])
{
   double leastFood; 
   int leastMonkey;  
   int leastDay;     
   int monkey = 0;  
   leastMonkey = 0;
   leastDay = 0;
   leastFood = food[leastMonkey][leastDay];
   

   for (monkey = 0; monkey < MONKEYS; monkey++)
   {
      for (int day = 0; day < DAYS; day++)
      {
         if (food[monkey][day] < leastFood)
         {
            leastFood = food[monkey][day];
            leastDay = day;
            leastMonkey = monkey;
         }
      }
   }
   
 
   cout << "Monkey number "  << (monkey + 1)
        << " ate the least amount of food,\n"
        << leastFood << " pounds, on day "
        << (leastDay + 1) << endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I guess you want us to write the program for you. Ain't going to happen in this lifetime. Show us that you have made an effort and posted the code you have written.

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

But you did give them rep -- the comments prove that. You will not see the amount of rep points either given or taken away in the arrows -- only -1 for negative or +1 for positive. You have to look at the person's avatar to see actual rep that the person has after you gave yours.

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

In the two functions that contain the errors. I posted an example of what needs to be changed.

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

you did something wrong, but since you didn't post any code I have no idea what you did. The same change has to be made to two different functions.

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

Move the declaration of monkey to the beginning of the function to make its scope function-wide. Then do not declare it in a loop

void foo()
{
   int monkey = 0;
   for(monkey = 0; // blabla)

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

variable named monkey has not been declared or is not in current scope.

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

I've seen that same behavior too on occasion.

jingda commented: Glad we are in the same boat +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

put the difigits in an array then sort the array.

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

That's where we found out that Narue is really an alien from Venus (see the UFO thread).

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

what you apparently want is an array of _bstr_t objects. The COM way of doing that is to create a SAFEARRAY. Here is an article about them. I don't know how to use them from C#, but since your code used _bstr_t class then I would assume that it can use SAFEARRAY.

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

Have you already written the delete function? View would be very similar.

How to do them will depend on how you designed the text file. There are as many ways to do that as there are programmers to program it.

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

yes you can compile it with that compiler. Do if you have MyDir.exe then you would type on the command line MyDir c:\somepath\*.c <Enter Key> I don't know what you mean by <filename.exe>.

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

Get that utility program then call it from your C program.

Or if you want to do it all from within your C program, read this Microsoft document and example programs.

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

You have to use a compiler to convert the solution *.c file into *.exe file. You can not execute *.c files. There are at least two good free compilers for the MS-Windows operating system: Code::Blocks and VC++ 2010 Express. Choose either one you want, but you might find Code::Blocks a little easier to learn.

MyDir is not the name of an executable program, but just the name of the directory that contains the *.c files you want to list.

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

The parameter to FindFirstFile() is wrong. If you want to find all the files in c:\\MyDir *.c then use that as the parameter to FindFirstFile.

Note: The code below has not been compiled or tested. This is supposed to concantinate all the command-line parameters to make a single path statement. For example, if you type on the command line myprog c:\MyDir <space> *.c then it should result in "c:\MyDir\*.c"

int main(int argc, char* argv[])
{
   char path[_MAX_PATH] = {0};
   int i;
   for(i = 1; i < argc; i++)
   {
      strcat(path,argv[i]);
      if( i < argc)
        strcat(path,"\\");
   }
   find = FindFirstFile(path,&found);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You give it a try yourself, then post back with the code you have written if you have more questions. Yes you may have to do some studying about FILE* and associated functions which I can not do for you. Also google around for c file handline tutorials to help you out with your research. Nothing teaches you better than when you research and discover the solutions to these things yourself.

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

Open the original file for reading. Open the new file for writing. Then in a loop read a block of data from the input file and write it back out to the output file. Since we don't know whether the original file was write in text or binary mode its always safest to assume binary mode. And I like to read blocks of data in chuncks of 255 bytes, but you can make it almost anything you want.

open input file in binary mode
open output file in binary mode
loop
   read a block of data from input file
   write the block to output file
end of loop
close both files
kumarmpk4u commented: His views helps me a lot +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

sounds like you are talking about MS-Windows. dlls "and crap" are used to make the exe files smaller. If you have two *.exe that each use function foo() then put function foo() in a dll so that all *.exe programs can use them. dlls are libraries of pre-compiled code that your program can use without the need to compile the sourcve files. All (or most) win32 api functions are in that category.

The *nix equivalent of DLLs are called shared libraries.

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

you forgot to make pointer b point to anything. struct s* b = &a;

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

Forgot to post this in Form1.h

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 ChangeFormText(this);
             }
jonsca commented: Nice job wrangling this thread into submission :) +14
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It doesn't work because ChangeFormText() allocates a new object of type Form1 and changes it text. That object is immediately destroyed when ChageFormText() returns to its caller.

You will have to put ChangeFormText() in Form1 namespace and add Form1^ parameter. Also the project I gave you does not contain a button.

// general.h
#ifndef GENERAL_H
#define GENERAL_H
#include "Form1.h"
namespace Form1 {
void ChangeFormText(Form1^ form1);
};
#endif
// general.cpp
#include "stdafx.h"
#include "Form1.h"

namespace Form1 {

void ChangeFormText(Form1^ form1)
{
form1->textBox1->Text="Hello!";
}
};
// Form1.h (first few lines)
#pragma once

namespace Form1 {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

    ref class Form1;
    extern void ChangeFormText(Form1^ fm);

	/// <summary>
	/// Summary for Form1
	/// </summary>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Portgas D. Ace commented: Good Form +0
Arbus commented: nice +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Attached are all the files I used. There must be something wrong with the way you are trying to do it. Compare the files I have with those you have.

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

search www.codeproject.com. It has probably the largest repository of C++ and MFC code available on the net. If there is such a control, then they will have it.

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

The problem now is that in general.cpp you have to identify the namespace that Form1 resides in.

#include "stdafx.h"
#include "Form1.h"


void ChangeFormText()
{
Form1::Form1^ form1 =gcnew Form1::Form1;
form1->textBox1->Text="Hello!";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
//General.cpp
#include "StdAfx.h"
#include "general.h" // <<<<<<<<<<<<< add this line
#include "Form1.h"
void ChangeFormText()
{
	Form1^ form1 =gcnew Form1();
	form1->Text="Hello!";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

delete line 4 from general.h. form1.h isn't needed in general.h