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

You're right, I was just checking to see if you were paying as much attention as I was :) :)

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

Vijay: The second suggestion won't work because the function return values are not consistent with parameter expectations.

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

Welcome to DaniWeb. Please don't hijack someone's thread to ask your question. Giving you a freebe this time because this is your first post :)

You probably need to create another thread for that timer to run in so that it will execute independently of the scanf() function. Exactly how to do that will depend on the operating system and possibly the compiler you are using.

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

I like that chess game too -- I have it set on the easiest level so that I can easily beat it :)

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

Has anyone tried to get a perfect game ? I've been trying now for a couple months to win without taking any points but can't seem to get beyone a couple hands. I've done it several times on XP, but have yet to accomplish it on Vista. The best I've done is win with only 1 point, but never with 0.

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

Q1 and Q1 are not that difficult -- try to write them yourself. Have no clue what Q3 is supposed to be. The trailing periods have no meaning.

Q1: create an array of 5 ints, initialize them to 0. Then use ifstream object to read the file one int at a time. After verifying that the number just read is in valid range 1-5 use it as an index into the array. Here is a hint:

int array[5] = {0};
int index;
cin >> index;
if( index > 0 && index < 6)
   array[index-1]++;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Hello Pete, welcome to DaniWeb.

>>my son who knows more than me
Kids always think they know more than their parents :)

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

Welcome to Daniweb. Hope to see you around.

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

Welcome to DaniWeb. Dam -- I didn't see catweazle. Any chance of getting it on DVD?

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

>>can i remove the extern C as well.
No, leave that as it is since you want to use the DLL with C code. If you're going to only use it with C++ then you don't need it.

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

nothing like digging up a 3-year-old thread :)

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

Oh now I understand. If you want the source code for that program you will have to ask the program's author for it. It will be free if its distributed as freeware, otherwise you will probably have to pay some money for it.

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

>>even when a program is very simple and absolutely correct

>>t shows "Fatal error... can't find path...."

Two completly contridctory statements.

>>what's the reason?
Your program has one or more bugs. Post code because I have a hard time seeing your monitor from my home :)

Also what Operating system ? If *nix make sure the executable file is in a directory in your PATH environment variable or use "./program " to execute it to indicate to the shell that its in the current directory.

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

There are several ways to resolve the problem. Maybe the simplest is to have a vector of structures

struct exams
{
    int id;
    int count;
};

Then have a vector of those structures. When you read a line search the vector to see if there is a structure for the exam id that was just read. If there is, then increment the count. If not, add a new structure

int course;
string student;
..
...
vector<exams> ex;
while( in >> student >> course)
{
     // search ex to see if there is a structure already in it
     // with the same course number.  If there is then just
     // increment the count.
     // if not, then add one and set the count to 1.
}

<map> would be more efficient way to do it, but that depends on if you know how to use it.

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

Why did you start a new thread? You should have just added to your existing thread so that people would know what in the world you are talking about.

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

First you have to know what the file looks like. Post the first 4 or 5 lines.

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

See post #17 here, which is the identical problam that you have.

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

>>I want to do like this, but how to open the file to read the examid?
Not sure what you want? This maybe: ifstream in("filename");

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

open() wants char*, not a string, so you have to use the string's c_str() method myfile.open(id.c_str());

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

It depends on what preceeded the cin.get().

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

how is id defined?

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

The error is because you have embedded the quote sysmble " within the path -- you can't do that. You will have to format the filename before calling the open function, something like this:

#include <sstream>
#include <string>
#include <fstream>
using namespace std; 

int main()
{
    ofstream myfile;
     int id = 12345;  // some id
     stringstream str;
     str << "account/" << id << "/example.txt";
     myfile.open(str.str());

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

Welcome to DaniWeb -- being a mom is the world's toughest job. Glad to see that you have some time to spare while the kids are in school and the baby's asleep. Narue, our Super Mod, is also a mom and a damed good programmer too. So I know you will get lots of excellent help here at DaniWeb.

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

>>hopefully this is an easy question
Ok, I'm not a mind reader so please state the question.

delete stdlib.h and conio.h because they are not needed in c++.

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

run the program from a command window instead of from Dev-C++ IDE.

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

file.seekg(...) will work in all cases if you seek to the beginning of the file.
otherwise, if the streampos that you use for the seek wasn't one returned by an earlier tellg on the same stream/filebuff, all bets are off. c++ throws in locale dependent character code translation, even when the char_type of the stream is just a char. you migh end up on the second byte of a multibyte character sequence or on the lf of a cr-lf sequence.
if you open a file stream (where the char_type of the stream is just a char) in binary mode and imbue the "C" locale, which will always result in a constant character width equal to one, you can seek to an arbitrary position.

Huh??? I'm sure what you said is probably accurate, but I have no idea what it is.

seekg() works the same in both text and binary mode on both *nix and MAC, Only in MS-Windows and MS-DOS do we run into trouble with text mode seeks due to the two-byte line terminators. I have no idea how it works on non-English file systems, presumably the same.

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

>>ok, so file.eof() would only work (correctly) if the file is opened in binary mode
No, it works in text mode too. But not the way yo would think it should. fstream only sets the eof flag after an attempt to read beyond the end of the file. The last time getline() is executed it will fail because eof has been reached, the flag is set, but in your original program x is increatemented anyway causing the value of x to be one too many.

>>then file.clear() and file.seekg(...) shouldn't work correctly either
clear() and seekg() work in either binary or text mode. seekg() just has a few limitations in text mode when working in MS-Windows operating system because of the two-byte record terminator in the file system. *nix and MAC don't have that problem because they only use one character record terminators.

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

So what got you "stuck" ?

>>Can anybody tell me what condition I have to use here?
Sorry but I'm having trouble seeing the code on your computer. Please post on DaniWeb.

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

>>If anyone knows where and how to place adds let me know
Check out all the Sight Management forums. Otherwise, advertising is strictly forbidden on DaniWeb. You can, if you want, put your link(s) in a signature available in the Control Panel, link at the top of the page.

Ads also here

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

Besides, if members that die of old age are never taken off the list, the average age over time will tend toward 100+

Agreed -- but that would take another 90 or so years and I know Dani isn't even close to that age (yet) :)

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

you are looking for a masked edit control

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

Are you talking about a disassembler -- a program that takes a *.exe file and converts it to assembly language ?

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

Post what you have done so far to write that program. We don't write your program for you.

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

>>Yes, thank you again, sir.
Please don't call me sir -- I had to work for a living :)

>>Thank you again, for taking the time to stop and answer a newbies ?
No problem -- that's what we're here for :)

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

hi, this should be a fairly simple question to answer. I have a function in my program that takes the content of a text file and populates an array with all the information. First it has to see how many lines the file has (as it can change) so it can create a dynamic array based on the number of lines.

if(file.is_open() && (get_file_size() > 0)) //get_file_size checks file size
        {
                while(!file.eof() )
                {
                        getline(file,temp);
                        x++; //number of lines
                }
        }

That part works fine, it's this next part that gives me the trouble.

No it does not work fine. Actually it may probably results in the wrong value of x because eof() doesn't work the way you think it should. Here is the correct way to code that loop

while( getline(file, temp) )
    ++x; // number of lines
while(!file.eof() )
        {
                end = 0;
                getline(file,temp);
                for(int z=0;z<2;z++) //hardcoded for number of fields to get
                {
                        end = temp.find(" ");
                        data[y][z] = temp.substr(0,end);
                        temp = temp.substr(end+1);
                }
                y++;
        }

The above code has the same problem with eof().

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

I suppose if you have a program that contains 1,000 lines you should have an int array of 1,000 ints and do something like this

int counters[1000] = {0};

int main()
{
    counters[__LINE__]++;
    cout << "Hello World\n";
    counters[__LINE__]++;
    return 0;
};

__LINE__ is a macro that returns the current line number of the program. I'm not certain if that macro is available on all compilers or not.

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

Google should be the first place to ask questions because it can often get you the answers very quickly. And we've had that same question asked here on DaniWeb a billion times -- once just this morning that I know of.

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

Dam -- I meant to vote for 100+ but hit the wrong button :)

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

How about this editor?. Don't know a thing about it though.

There aren't many people who use Turbo C anymore so help you get will be very limited.

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

1) system("pause") is not portable -- only works on MS-Windows and MS-DOS operating systems.

2) cin.get() is a lot faster

Other reasons

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

im running msvs6.0
is it my compiler?

Yes. Why are you still using that ancient compiler? You might as well chizzel out your program on a piece of rock with Hammer & Chizzel :) VC++ 6.0 will let you do a lot of things that aren't c++ complient. Download the latest free Microsoft VC++ 2008 Express.

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

what are the errors when you attempt to compile on ACM?

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

I doubt you will ever find a perfect word list -- afterall even Websters dictionary contains foreign words, acronyms, abbreviations etc. Then there's the issue of whose version of English do you want to use? Oxford English, The Queen's English, American English, etc. Then what will you do with all the foreign words ?

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

lines 113-117 are wrong, you have them backwards. See the lines I posted. I think you also have them in the wrong event handler. Should be

private: System::Void BuyRadio_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			    if ( IsClicked )
                     IsClicked = false;
               
				else
                     IsClicked = true;
             }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No, I guess it means AD will get a job at Pentagon :)

Already had that one and don't want another. :)

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

>> I have trid to press the button without pressing the radiobutton also.
what does that mean?

At this point I think you need to post the code for the form that contains the radio button.

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

The way I did it was like this: (see line 10 and 28)

public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
                           this->IsClicked = false;
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
    private: System::Windows::Forms::Button^  BuyRadio;
    protected: 

	private:
        bool IsClicked;
<snip>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you trying to do this from C++? or from Delphi? If Delphi you are on the wrong board and I'll move it to the correct board.