Murtan 317 Practically a Master Poster

I agree that I generally don't use the this pointer.
About the only time I use it is when I call a method or function outside of the class that needs to refer back to my object.
An example might be registering my object with a 'server object' for callbacks.

Murtan 317 Practically a Master Poster

Side comment - with 18 post under your belt, you should have known enough to wrap your code in code tags.

[code] ... your code here ... [/code] at least, but for this forum, preferably [code=c#] ... [/code]

Murtan 317 Practically a Master Poster

If you don't intend to use any of the predefined C++ data types in your implementation, what do you propose to use?

A 6000 byte long number could be implemented, I would probably use an array with 6000 elements, but that still uses base C++ data types.

(Ignoring the fact that arbitrary precision math class is probably already available.)

I'd recommend getting over the "I don't want to use the ___, how do I do ___" mentality and focus on the objective of what you want to be done. Use the tools that are available.

If you don't have an objective that has been assigned, from school or work, then develop your own objective and assign it to yourself. This question appears to be argumentative on the surface. If you have a real-world situation that would make this line of inquiry make sense, feel free to present it.

BevoX commented: Thank you for your answer it reflects you also like to think out of the box. :) +1
Salem commented: Good +29
Murtan 317 Practically a Master Poster

If the code you want to call belongs to an object on the same page as the javascript, I think you can make it work.

If the javascript is running in an embedded browser and you want it to call code in the surrounding application, I don't think you can call it directly. You might be able to do something with a network packet or socket, but that doesn't sound like what you were looking for.

Murtan 317 Practically a Master Poster

do the overloaded operators need to be implemented as members of the class, or could they be implemented 'outside' the class?

(I think in class may be required or recommended)

Do you need to have the operators return a value?

Murtan 317 Practically a Master Poster

You should be getting compile errors with that code.

functionb is not declared properly

functiona needs a loop (for loop?) and the input statement.

The prints for largest and smallest should be from the main code and not from in functiona or functionb

both functions need to 'return' what they found.

Murtan 317 Practically a Master Poster

I thought AncientDragon explained it pretty well.

Your assignment is to create a couple of functions which implement the menu options 'A' and 'B'. When you're done, the person running the program shouldn't be able to tell that you have made any changes, the program should still behave as it does.

The instructor also pretty clearly stipulated the interface to both functions. The first function must take the quantity of numbers as an argument and return the largest number entered. (So the main code will need to prompt for the quantity of numbers and display the largest.)

The second function is to take no arguments and return the smallest number entered. (So the main code will need to display the smallest number.)

He wants the switch to look something like this:

switch(letter)
{
    case 'A':
        // prompt for the quantity of numbers here
        largestnumber = menuOptionA(numbers);
        // display the largest number
        break;
    case 'B':
        smallestnumber = menuOptionB();
        // display the smallest number
        break;
}

(Though those are bad function names, you can do better. I also didn't declare the largestnumber or smallestnumber variables, feel free to change their names as well.)

Most of the code that used to be in the switch statement will be 'inside' the new functions.

Murtan 317 Practically a Master Poster

My prototype (really simple -- uses 3 copies of the sample data you posted) seems to work ok. I do parse the first input file 4 times (once for each of the fields I want). Then for each remaining file, I parse it for the 4th field and output the line.

The second parse of the first file looks like this:

ifh.seek(0,0)
ostr = ""
for line in ifh:
    ostr += "%-7s" % line.strip().split()[1]
ofh.write(ostr)
ofh.write("\n")

The value 7 was determined arbitrarily and is just used to make the data look pretty. Because you have 9126 columns and each column will take up 7 spaces, each line will be 63882 characters long (seems a bit much to me, but I think it will work).

Murtan 317 Practically a Master Poster

So there will be 9126 columns of output (one extra for the headings)
and all of the values from one input file will be on one line in the output file?

Is the output file intended to be human readable or computer readable?

Human readable means you do things like try to line up decimal points and try to make the output 'pretty' when someone looks at it.

Computer readable means making it easier for the computer to extract the data.

So back to the algorithm

For the first file, we want to extract all of the fields, but can not print out the fields as we go unless we want to process through the file four times (not necessarily a bad idea, but could be inefficient).

The first line in the output file is the header followed by all of the first field values. The second output line is the header and the second field values. The third output line is the header and the third field values. The fourth line is the header and all of the fourth field values.

After the first file, the remaining files could be processed file-by-file and line-by-line:

For each remaining file
    Print the header
    for each line in the file
        print the fourth field value
    terminate the output line
Murtan 317 Practically a Master Poster

It might help if you could write (in your own words) what it is that you think you need the program to do.

The first example looks something like:

There are 10 (or N?) input files with line-oriented records.
Each input line contains 4 fields.
Generate an output file that aggregates the data from the input files.
Each output line will contain:

  • the first 3 fields from the line in the first file
  • the fourth field from each of the files

There will be one output line for each of the input lines.

My guess is that the first 3 fields identify when the sample was taken (date?) and the 4th (last?) field is the sample.

Does (or should) the program do anything to make sure that the collection date is the same in all of the files?

Would it be possible that one (or more) file(s) might not have data for a given date?

Having a better idea of what you're trying to accomplish will help us help you.

Murtan 317 Practically a Master Poster

@starzstar

I think the module you're looking for it getopt

It is designed to parse command line arguments and handles the type you indicated.

@keerthihm

You should probably have started your own thread and not replied to this one.

You seem to be asking about testing a binary tree.
Which are you wanting?

  • help testing a binary tree algorithm
  • help calculating the number of comparisons that must be made when searching a binary tree
slate commented: Clears things up. +1
Murtan 317 Practically a Master Poster

I like using random.shuffle() on the unused cards (or deck) and then you can just pop() a random card off the unused list.

If you need to keep a used cards list, you can append the card you just got.

When it is time to shuffle again, you can refill the unused cards and random.shuffle() again. This would also work with more than one deck of cards if it was desired.

Murtan 317 Practically a Master Poster

Thanks for using [code]

[/code] tags, but your formatting could still use some work :)

If you use [code=c++] [/code] tags, the code will have line numbers and syntax highlighting.

The first section trying to validate input:

cout << "Please enter in your desired amount of lines for your"<< endl;
cin >> lines; 

if(lines>max_lines)
{
	cout<<"limit is 30 lines,please enter again\n";
    cin>>lines;
}

needs to be in a loop so it can keep checking.

For this type of application either use a do { /* ... */ } while ( test ); or a while (test) { /* ... */ } where you make sure the test passes at least once.

This is an example of the second case:

lines = 0;
while (lines < min_lines || lines > max_lines)
{
    cout << "Please enter in your desired amount of lines for your"<< endl;
    cin >> lines; 
    if (lines < min_lines)
    {
        cout << "You must have at least one line.\n";
    } else if (lines > max_lines)
    {
        cout << "You can request at most 30 lines.\n";
    }
}

(This was in the 'post' buffer while I had to go play taxi driver)

Murtan 317 Practically a Master Poster

Just a comment:

return len(possibles) / len(winners) * 100.0

Calculated the wrong percentage

I changed it to:

return 100.0 * len(winners) / len(possibles)
Murtan 317 Practically a Master Poster

As this appears to be your third post on the same topic (different forums) in less than a week, I have to ask, did you read the FAQ's?

We will generally not provide a canned solution for you, we will help you to develop your own solution to the problem, but you're going to have to do most of the work.

If you think you're up to the work part, lets start by developing an algorithm. Lets think about how you might go about solving the problem manually and then we can try to adapt that to a solution.

So if I understand your problem description, the 'real-world' equivalent would be something like the following.

I've just handed you a pile of 3x5 cards, each of them has a name on it (this is to represent the filenames of your jpgs) and I give you a stack of envelopes.

Your job is to group the cards into sequences and put the cards from a sequence into an envelope and label the envelope. (This represents the folders you want to create.)

What steps would you follow to group the cards and put them in envelopes?

Murtan 317 Practically a Master Poster

oops

Murtan 317 Practically a Master Poster

The code

cout << "It will take " << W.getDays() << " days and " << W.getHours(); << " hours of time." << endl;

should only have one ';' after the endl. The one after W.getHours() does not belong.

Murtan 317 Practically a Master Poster

I'm sorry, did you bother to read my post at all?

/* TAking input from user and storing it in ArrTemp array */

fgets(ArrTemp, ARR_TEMP_SIZE, stdin); 

for(iLength=0; iLength<ARR_TEMP_SIZE; iLength++)
{

/* value in ArrTemp is now stored in Dept_Name */

ArrTemp[iLength]=Dept_Name[iLength];
/* ** ** The above line assigns ArrTemp[ii] with the value from Dept_Name[ii]
   ** ** OVERWRITING the value the user just entered. */
}

You're still calling fnAddDepartment() from within fnAddDepartment, most times without closing the dept file.

You did fix the size of acLine.

You have your file reading all wrapped around input validation for the department name. You have code that does not depend on individual characters to validate inside the loop to validate individual characters.

Your file reading needs to be in a loop, but it is not.

Your if statement comparing each of the characters in the entered department name could be made more readable.

You have:

if(Dept_Name[iCount]==32 || Dept_Name[iCount]==38 || Dept_Name[iCount]==45 || 
		   (Dept_Name[iCount] >= 65 && Dept_Name[iCount] <= 90) || (Dept_Name[iCount] >= 97 && 
		    Dept_Name[iCount] <=122))

This is equivalent and much easier on the eyes:

if ( Dept_Name[iCount] == ' ' || 
     Dept_Name[iCount] == '&' ||
     Dept_Name[iCount] == '-' || 
    (Dept_Name[iCount] >= 'A' && Dept_Name[iCount] <= 'Z') ||
    (Dept_Name[iCount] >= 'a' && Dept_Name[iCount] <='z'))

Please modify the function to group more of the code together.
Before you even open the department file (why aren't you calling fnOpenFile() anyway?):

  • Prompt the user to enter the …
Murtan 317 Practically a Master Poster

The limit for the 'i' loop in bubbleSort() is interesting, but it appears that it would work.

You will probably need to allocate the array and fill it with the data you read from the file. Then you will need to call bubbleSort() and pass it the array and the count.

Are you supposed to output the sorted array?

You should be doing your own testing on your application. You should create some data files with known data in them. You should manually calculate the count and average. Then when you run your application with your file as the input, you know what results the program should produce.

The goal of your testing is to find the problems yourself before someone else can complain. If you find your program is not producing the output you want, we can usually help.

Post the code, the data file and the output. Include the problem definition statement, something along the lines of: "When I run this program I expected to see ____ but I'm seeing ____ instead." or something similar.

Murtan 317 Practically a Master Poster

problems in fnAddDepartment():

fgets(ArrTemp, ARR_TEMP_SIZE, stdin);
    for(iLength=0; iLength<ARR_TEMP_SIZE; iLength++)
    {
        ArrTemp[iLength]=Dept_Name[iLength];
    }

The first line gets input into ArrTemp, the remaining 3 lines overwrite the input with the previous name (which at the time it is used is undefined.)

You should be using looping constructs inside fnAddDepartment() and not just calling fnAddDepartment() again if you have a problem. (Mentioned in WaltP's post)

The target buffer char acLine[25]; is not big enough to handle the default case for sprintf(acLine, "-20%s %4d", Dept_Name, Dept_Code); The minimum number of characters to hold that print is 26 (with the terminating '\0'). The function you use (sprintf) will NOT check and will NOT care. There might be special cases (if Dept_Name was ever longer than 20 characters, or if Dept_Code was > 9999) where it might need more characters.

I suspect the first issue above is the one that's causing your present trouble, though the second one is problematic and the third will overwrite one byte of memory not belonging to the output string.

Murtan 317 Practically a Master Poster

TestClass has no means to find the DbConfig declared inside main.

If TestClass needs to access it, that DbConfig must either be given to TestClass as a parameter of some sort or if having one and only one DbConfig would be proper, you could provide support for and access to the 'global' DbConfig via a singleton implementation.

The DbConfig declared inside TestClass::testDSource() is unrelated (as it applies to data) from the one in main().

Murtan 317 Practically a Master Poster

Whether or not the source is available for a given library is up to the developer of the library.

If the source files are not included, you can't step into them. (Unless you like to read disassembly.)

If the library is only released as a dll, the same applies.

If you are having problems with a library that was released without source, you are generally not supposed to attempt to debug it.

If you are having a problem with such a library, you confirm that you are using the documented interface and then 'prove' that the function you call does not behave as documented. You then 'present' the evidence to the library supplier and they will usually fix the problem and release an updated library.

Murtan 317 Practically a Master Poster

Looks like a nice homework problem, maybe if you put some work into it first, you might actually get an answer.

See Homework Help

When you start posting code so we can help, use code tags

If you have absolutely no idea where to start, show us your design (how you think the program should work) and ask specific questions.

Murtan 317 Practically a Master Poster

The iofile.seekg(pos) appears to be an offset seek (as in it seeks forward from the current file location by default).

You might try iofile.seekg(pos, ios::beg); to see if the in-place updates work.

PS- turbo c++ 3.0 is VERY old, you might consider upgrading to a more modern compiler. One option would be Visual C++ Express (It is free to download and I believe it is free to use -- as long as you don't make money with it.)

Murtan 317 Practically a Master Poster

I've always thought that the 'snake' collision detection just looked at the next square the snakes head was going to be put. If there's something in the square, its a collision. If its food, the snake eats it and that's a good thing. If it's wall or part of either snake, it's a bad thing.

As long as you apply the same rule to both snakes, it should be able to detect collision with objects for either snake.

Salem commented: Seems like a plan to me +27
Murtan 317 Practically a Master Poster

You may have BGI files, but I didn't and so I had to modify the code to get it to compile. I'm running Windows, and as I understand it, BGI is not compatible.

Maybe if I make the questions BIG you'll answer them:

WHAT COMPILER ARE YOU USING?

WHAT OPERATING SYSTEM ARE YOU RUNNING ON?

The point I was making about the seeks, was that one is using ios::beg and the other wasn't, it may be the default, but you made a point of passing it to one and not to the other.

Why use tellg to get position for one file and use a record counter and a mulitply for the other file? Why not use the same method for both files?

(I'm picking at differences between the two because you say one works and the other doesn't.)

If I've been reading through the code correctly, it is designed to loan (issue) one book (that has not already been issued) to the member (that does not already have a book). Is there any sense or record of which member has which book?

Would it ever be desired to issue more than one book to a member? (I know my local library will :) )

This application seems like it would lend itself well to a database, might that be an option for ongoing development?

I took your last issue book posted and I'm trying to work with it, but …

Murtan 317 Practically a Master Poster

That's still pretty painful to look at, maybe if your code tag worked (use [code=c++] to start it (no spaces in the tag).

You have a for loop that i think was supposed to be closed, but was not:

for(int index=5; index<10; index++)
{random_integer = (rand()%10)+1;

Did you mean to put a closing '}' on that second line?


Taking a section of code, (with the problems in it) ... putting each brace on its own line and eliminating extra braces and adding any missing braces.

if (array[0]==1)
{
    for(int index=7; index<12; index++)
    {
        random_integer = (rand()%10)+1;
    }
    enhp = enhp-random_integer;

    if(enhp< 1)
    {
        cout<<"Victory"; 
        break;
    }
    else
    {
        cout<<"You have done "<<random_integer<<" damage.\n";
    }
}
else if (array[0]==2) 
{
    cout<<"You have fled"; 
    break; 
    break;
    system("pause");
    return 0;
}
else
{
    cout<<"Invalid response, please choose again.";
    system("pause");
}

Is that closer to what you want?

Does that compile?

Murtan 317 Practically a Master Poster

I thought of a way to write your program without using the '||' operator would be to double the ifs and have 2 sections for each.

if (m == 3 && d >= 21)
    printf("\nYour star is ARIES");
if (m == 4 && d <= 19)
    printf("\nYour star is ARIES");

See no '||' but it will be longer and return the symbol twice.

I just thought of another alternative (I'm full of good ideas today :) ):

if you did something like:

/* Put the month and day together as MMDD in a single int */
int birthmd = m * 100 + d;
if (birthmd >= 321 && birthmd <= 419)
    printf("\nYour star is ARIES");

Even cleaner and still no pesky '||'

Murtan 317 Practically a Master Poster

Actually, that code tag message was intended as a reply for yabuki

But if you're not posting your code with code tags, feel free to use them :)

Murtan 317 Practically a Master Poster

You already have a 'global' (ok so it is local to the class, but all of the class methods can see it) data area defined. See this section under private in your class:

private:
	double average;
	string courseName [4];
	char  gradeLetter [4];
	int gradePoint [4];

The only reason you aren't sharing the data is because you hide it by re-declaring the same variables inside your functions:

Here

void displayMessage ()
	{
		char  gradeLetter [4] = {};
		string courseName [4] = {""};

and here

double getAverage ()
	{
		int gradePoint [4] = {};
		char  gradeLetter [4] = {};
		double average = 0.0;

You can just comment out (or delete) the declarations under each function and they will use the class data, sharing it between them.

I noticed why you aren't having to enter four grades for each class, it is the break inside the for (y ... loop.

I might ask why you even have that loop anyway. Why not just do something like the following? (I have commented out your code where it is not needed or where I have modified it.)

void displayMessage ()
	{
		//char  gradeLetter [4] = {};
		//string courseName [4] = {""};

		for ( int x = 0; x < 4; x++ )
		{
			cout<< "Please enter name of course:";
			getline(cin, courseName [x]);

			//for ( int y = 0; y < 4; y++ )
			//{
			cout<< "Enter grade recieved:";
			//cin>> gradeLetter [y];
			cin>> gradeLetter [x];
			//	break;
			//}
			cin.ignore …
VernonDozier commented: Good advice. +11
Murtan 317 Practically a Master Poster

I don't think I can be much more blatant.

When you type:
[code=c] int main() { printf("Hello, World\n"); return 0; }

[/code]

It looks like this when you post it:

int main() {
    printf("Hello, World\n");
    return 0;
}

The article that talks about it is at http://www.daniweb.com/forums/thread93280.html

Murtan 317 Practically a Master Poster

That's very pretty code, but it should have been posted using code tags.

When posting c code, please use c code tags
[code=c] /* Your code here */

[/code]

And logically, the if statements you have don't meet the needed criteria.

For example your first if: if ((d>=21 || d<=19) && (m==3 || m==4)) Is valid for the following dates:
3/1 to 3/19, 3/21 to 3/31, 4/1 to 4/19, and 4/21 to 4/30

(blatantly borrowed from Wikipedia)

Under the tropical zodiac, the Sun is in Aries roughly from March 21 to April 19, by definition beginning at vernal equinox.

Murtan 317 Practically a Master Poster

When you run the code, are you still having to put the grades in 4 times or did you fix that?

Could you post your new code?

Murtan 317 Practically a Master Poster

Quoting ... again:

In elapsed(), realize that t1 is the 'start' time and t2 is the 'end' time, and think back to your basic math:

  • How much time has elapsed between 08:45 and 10:15?
  • How did you figure out that it was 01:30?
  • Make the computer do that...

You appear to have the same code in elapsed. You initialize duration to zero, compare it to t1 and t2 without doing anything with either value and return.

Perform the calculation suggested in the quote above using the hours and minutes from t1 and t2 and THEN initialize duration from the calculated value.

Murtan 317 Practically a Master Poster

You're not using the same style of seek for both files.

iofile.seekg(pos);
    ifile.seekg((rec2-1)*sizeof(b1),ios::beg);

The user file never gets closed.

ifile.close();
mainmenu();

You're still calling for a new mainmenu().

You didn't answer the Compiler and O/S questions.

Murtan 317 Practically a Master Poster

Did you see the note about code tags?

When posting c++ code, please use c++ code tags
[code=c++] // Your code here

[/code]

Murtan 317 Practically a Master Poster

I agree with all of Lerner's comments.

I decided your problem looked like fun so I decided to try and get it to compile on my system.

What Compiler are you using?

What is your target Operating System?

(My compiler didn't have support for the BGI graphics so I had to comment it all out -- and fix several other things that relied on it working.)

First major oops is that you keep calling mainmenu() to return to the main menu. That does NOT return to the main menu, it calls a brand new mainmenu that in theory would return to where you called it from, but your mainmenu() as coded will never return.

Every time you make a menu selection and return to the main menu your stack gets a little smaller, eventually (if you ran the program long enough) you would run out and the program will fault.

I'll keep converting and trying to get it to compile / run. But a good specific question would be very helpful. (Something like "When I select ___ from the ___ menu, I expected to see ___ but I see ___ instead. What did I miss?" gives good location and information.) The better the information you give the more likely you are to get a useful answer.

Murtan 317 Practically a Master Poster

Why are you trying to re-declare h inside the if statement?

if ( int h > 10)

should be:

if (h > 10)

Which is what I typed in my example...are you trying to break your code on purpose?

Where's the code to print the ':'?

Where's the code to support minutes?

Murtan 317 Practically a Master Poster

I wasn't in your original chain...but I'll try to help.

(I ended up compiling and running your code in the debugger)

Your problem is that you have a pointer to a pointer and you're indexing off the wrong pointer.

I changed your code: fscanf(f1,"%d ",&pcall[i]->day); to this code: fscanf(f1,"%d ",&(*pcall)[i].day); (with all of the other lines in that section) and the code no-longer faults.

I also commented out the free(*pcall); as you are returning the array to the caller. Either don't pass pcall to getData and then you can free it, or don't free the data you're returning to the caller.

Murtan 317 Practically a Master Poster

AND and OR are 2 similar but different constructs.

month = 3 && month == 4
Is an impossibility, it will NEVER happen

month == 3 || month == 4
happens for months 3 and 4

Murtan 317 Practically a Master Poster

We're having a communication problem.

We are recommending that you create in memory a copy of what you want the file to contain. You are being specifically advised against trying to 'edit' the file as the user types keys.

The memory 'buffer' is what the user will edit. They can append to it, delete, whatever. (if you're having problems with editing in the buffer, ask about that.)

Once you have the buffer that is what should be in the file, you open the file, write the buffer and close the file.

If you're looking to make sure the file on disk is close to the buffer in memory, you could look into a periodic 'auto-save' of the file. (You could auto-save to the actual output file, but you should probably let the user know. Normally user files are only written on user command. Alternatively you could auto-save to a slightly different name -- like outputfile.asv or some other transformation of the real output name.)

Murtan 317 Practically a Master Poster

We don't do 'code to order' feel free to post your code and we'll help you work through your problems.

Or ask a much more specific question like 'How do I open a file'? if you can't find it on google (or equivalent)

Murtan 317 Practically a Master Poster

Rephrasing one of your if statements into english:

if (d>=21 && d<=19 && m==3 && m==4)

That reads: If the day of the month is both more than or equal to 21 and also less than or equal to 19 {this is impossibility one} and the month number is 3 and the month number is 4 {two}

What you want is something like:

If the month number is 3 and the day of the month is the 21st or later, OR the month number is 4 and the day of the month is the 19th or earlier

so you need to end up with a test that looks something like the following:

if ( ( ___ && ___ ) || ( ____ && ___ ) )
Murtan 317 Practically a Master Poster

Once you have both of those, you can use the two numbers to calculate the total weight of the widgets.

And if you know how much all the widgets weigh and how much a single widget weighs (and at this point you would know both of those) you can calculate how many widgets must be on the pallet.

Murtan 317 Practically a Master Poster

Your class has space for 4 class names and 4 grades.

But when you accept input from the user, you read a class name and then 4 grades for that class.

Then you read the next class name and 4 grades for the second class. (But you store the 4 grades from the second class where the first class did so you lost the 4 grades from the first class.)

Is your intent 4 classes with 1 grade each, or 4 classes with 4 grades each?

Murtan 317 Practically a Master Poster

I don't think you can use scanf and meet those criteria, scanf will not accept spaces.

I suggest using fgets and parsing the line you get back to validate.

Murtan 317 Practically a Master Poster

ok you could make that work, but you forgot to print the m and h...and you should probably print the hours first.

if (h > 10) {
    cout << h;
} else {
    cout << '0' << h;
}

Remember to put the punctuation in as well.

Murtan 317 Practically a Master Poster

How would you solve the problem manually?

I want to withdraw $180, what bills would you give me?

How did you decide how many to give me?

Ok now make the computer do it...

Write some code that asks how much to withdraw.
Add a print statement that outputs what it thought I entered.
(The last step might be temporary, but its always nice to verify the input works.)
Then write some code to have the computer follow the way you solved the problem by hand.
Add some code to output what you calculated.

Murtan 317 Practically a Master Poster

In my first test, it blew up trying to output grades when I had not entered any. (Maybe you should have a count for the number of grades that have been entered.)

Looking at the code for the grades:

while (count <= 10)
         {
         cout << endl << NIU_Student.courses[count].getCourseID() << " " 
              << NIU_Student.courses[count].getYearTaken() << " " 
              << NIU_Student.courses[count].getSemesterTaken() << " " 
              << NIU_Student.courses[count].getGrade() << endl;
         count++;
         }

You will index count from 0 to 10, and the 10 value is outside the range of the array.

I'm not sure why this isn't a for loop, but changing your while condition to while (count < 10) should make it feel better.

Murtan 317 Practically a Master Poster

Putting code in headers is generally bad form....if you include that same header in more than one file in a compilation unit you get duplicate symbols.

The original layout of the files should have worked, did you include myfile.obj or myfile.o when you compiled main.c?