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

1) The case statements need at break; statement at the end of the case to prevent other cases from being executed

case 1:
...
break;
case 2:
...
break;
// etc

2) You don't need to check the value of Deck within the case statements because that is already done in the switch statement.

3) You can't declare character arrays within if statements like that because they will disappear (go out of scope) as soon as the if statement terminates. Declare character arrays outside the switch statement so that they are in scope for the entire function.

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

Anyone know why my sound keeds getting set to mute? It gets set to mute every once in awhile, I don't know why.

Also, on related question, I have a set of Bose ear phones, the kind you stick in each ear (see thumbnail). The problem is that sound comes out one ear but not the other. I've checked the balance setting on the computer and both left/right are both set to the same thing, the volume setting is as high as possible, and I have tried wiggling the end of the cord that plugs into the computer. Nothing seems to correct the problem. Any ideas?

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

HAHAHA, Dragon is angry today.

Nope, not angry, just answering his questions. He has to learn to ask the right question(s) if he wants better answers.

That like someone asks me "Do you know what time it is?". I look at my watch and answer "Yes", then continue with what I was doing.

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

All I see in the code you posted is the function prototype for that function -- where in *.cpp or *.h file is the implementation code?

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

If he is sent to prison he will be the third governer in a row. Two others are currently in prison. Maybe the feds need to build a new prison just for state governors :)

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

>>for( ; fscanf( fin, "%d", &x ) = 1 ; i++ )

Two things wrong with that:
1) where is variable i declared?
2) need to use operator == instead of = (common mistake)
3) what happens when the value of i exceeds the size of the array x ?

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

>>can i read the contents of the table into a structure
I don't know -- can you ?

>>will i be able to print these contents in desired form
Here again, I don't know if you can or not. Only you can tell us that. And why should we care if you can or not?

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

Note for future homework: if the teacher assigns you to write a method, you probably need to call it for the assignment. If not, re-evaluate how you're doing the work, maybe you're missing something. (In any case, I would call all of my methods at least once or twice for testing, I hate it when the teacher finds a bug because I didn't bother to test.)

You are absolutely correct about that! Its important not only in school to test everything you write, but also every programming job you will get after graduation. Learn to do this in school and it will help you immensely after graduation.

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

>> Is there any way to do this?

check the user input string to see if it contains a path -- e.g. the '\' or '/' character (path separators can be either character in MS-Windows os). Copy that part in another string so that you can use it whanever needed.

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

>>it will look like this "theArray[...][3]??

No. It is a one-dimensional array of structures. So it looks like this theArray[...]

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

idots sure can -- see this thread I just posted

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

In case you have not heard yet, the Illinois governor was arrested today for attempting to sell the state's senate seat that Mr. Obama held to the hightest bidder. I'm supprised he didn't try to sell it on eBay. That isn't the end of it -- he was thinking of keeping the seat for himself and running for President when Obama's term ends :) :) What an idot.

http://www.msnbc.msn.com/id/28148126

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

>>ifstream in("C:\Users\Yaser\Documents\Visual Studio 2008\Projects\Vesta Coordinates\4vesta.txt");

I suppose you ignored all the errors and warnings your compiler gave you on that line ???? You have to double-backslash the directory separators ifstream in("C:\\Users\\Yaser\\Documents\\Visual Studio 2008\\Projects\\Vesta Coordinates\\4vesta.txt");

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

you have to know where the file is. Add the full path to see if the program will open it. ifstream in("c:\\myproject\\4vesta.txt");

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

you need to put getline() in a loop inside the function lookyLooky() so that it reads all the lines in the file. Then on each loop iteration use the std::string's find() method to search for the desired text.

while( getline(filename, line) )
{
    // check to see if this line contains the desired string
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My guess is the file is not open. Add this after the open

if( !in.is_open())
{
   cout << "Failed to open the file\n";
   return 1;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>What makes a good prgoammers?
Practice, practice and more practice. And a good deal of patience.

>>What made you get a job?
I don't like starving :)

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

call srand() only once during the lifetime of the program -- normally called near the beginning of main().

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

>>Any ideas??
Post the code that is giving the errors. We are not mind readers.

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

What do you think is the answer? Did you compile and test it for yourself? If not, why not?

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

There are a lot of things that VC++ 6.0 did that can no longer be done.

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

Practice problems mean you type them into your compiler, compile them, and see how they work. That's the best way to figure out how things work. For these, forget the internet -- pretend it doesn't exist. All you have is you, your computer, and your compiler.

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

member function readfile() only reads one record into the stucent structure. There should be a loop somewhere else in your program that puts that in a loop to read the entire file into an array of student records.

as for part b) -- You could have read() function return TRUE (or 1) if EOF (^Z) is not pressed, or 0 if it is pressed. Then call that function in a loop until it returns TRUE.

#include <iostream>
#include <string>

using namespace std;

int read(string& name)
{
    cin >> name;
    if( cin.fail() )
         return 0;
    return 1;

}

int main()
{
    string name;
    while( read(name) )
        cout << name << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

do is the top of a loop

do {
  // something here
} while ( <some condition here that stops the loop> );

I'm not going to answer the question you posted -- write a small test program and see for yourself what the answer is. Just post that code in a main() function and you have it done.

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

>>So is it not possible to use open function in VC++ 8.0?
Its a *nix function, not supported by Microsoft compilers. Dev-C++ supports it (I just tried it), and I would expect Code::Blocks to support it too because they are both based on *nix gcc and g++ compilers.

>>But it will cause a lots of change in that code.
That's one of the dangers of writing such low-level non-standard code. Your program isn't very portable to other systems and compilers.

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

Depends on the circumstances. Most of the time you will want loop counters to start at 0 because all arrays in C and C++ are 0 based, not 1 based. So the index number of the first element of any array is always 0. For consistency sake I always start loop counters out at 0 unless there is a good reason to initialize them with some other number.

A sorting algorithm is a good example of when to initialize the loop counter to something other than 0. Example

int foo(int array[], int nval)
{
    for(int i = 0; i < nval-1; i++)
    {
         for(int j = i+1; j < nval; j++)
         {
             // do something
         }
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what is the value of 5/9 ? Notice that is integer math, not floating point, so all decimals are lost. Once you understand that, its simple 2nd grade math to figure out the rest of the problem.

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

If you really want to port it to c++ then use fstream instead of those very low-level file functions. Its really not all that difficult once you understand it.

#include <fstream>
using namespace std;

int main()
{
     ifstream in(l_chBuff, ios::binary);
     // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is c++ board, not C#. Which language are you using?

__declspec(dllexport)  class clsName
{
   // blabla
};

then in the c++ file

__declspec(dllimport)  class clsName
{
   // blabla
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In order to use shared memory with more than one process or thread you have to implement some way to lock the share memory so that no more than one process/thread is accessing it at any given instance. Semaphores are often used for that purpose. Read some of these links, ignoring those that are for MS-Windows because they will not be relevent to *nix system.

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

>>for(wijzer=0;wijzer<=pointer;wijzer++)
what is the value of pointer

>>switch(PIND)
Why are you using a const PIND here? Can its value ever be changed somewhere else in your program? If not, then that switch statement has no purpose.

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

CreateDocument() is a member of a class, so in the application program you have to declare an instance of that class in order to call it, unless of course it is a static method. My suggestion is to export/import the entire class instead of just one method.

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

line 14: >> for(int a = 0; a <= NULL; a--)

Do you know the definition of NULL? Answer: 0. That loop will execute as many times as it takes for a to wrap back around to a positive number, which could be a whole lot of iterations. for(int a = 0; a <= 0; a--) line 17: >>if(front >= front->next)
Why are you comparing the address of two pointers? What good does that do? Aren't you supposed to compare the data object occupied by the nodes?

My guess is what you want is this:

void dynintqueueEX::smallest()
{
    int lowval;
    //CHECK FOR EMPTY QUEUE
    if(front == NULL)
    {
        cout<< "\nQUEUE IS EMPTY! \n";
        return;
    }

    //step through qeueu - starting with front
    //to find the smallest number in the queue
    queuenode *temp = front;
    lowval = temp->value;
    while(temp)
    {
          if(lowval > temp->value)
              lowval = temp->value;
         temp = temp->next;
    }    
    cout << "Low value is " << lowval << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

getline() doesn't work like that. What you want is this:

while( in >> lat >> lon >> R)
{
   // do something with that data

}

Now, if you want to keep all the data in memory at the same time, create a structure and then a vector of structures

#include <vector>
...
struct data
{
    int lat;
    int lon;
    int R;
};

vector<data>  theArray;
data d;
while( in >> d.lat >> d.lon >> d.R)
{
    theArray.push_back(d);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The while loop is incorrect

while( partin >> emp.id >> emp.skillLevel >> emp.yearsWorked)
{
    applicant.linkup(emp);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If it "bombed" during download then maybe the problem is your internet connection. I think you can order it on CD for minimal amount -- usually about $5.00 USD

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

>>#include "applicant.cpp"
Never, ever, under NO circumstances, do this!! DO NOT INCLUDE *.CPP like that. Instead, compile them separately and link the object modules. How to do that depends on the compiler you are using.

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

what kind of computer and operating system do you have? Amount of RAM and size of hard drive. You will need Windows XP with SP2 or Vista to run that compiler.

If you don't have that, then you can download free Code::Blocks or Dev-C++. Dev-C++ is getting rather old now and all development on it has apparently halted. Code::Blocks is pretty current.

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

In my case the old algorithm found exactly what I was looking for. The new algorithm flunked pretty badly (I'd give it a grade of F-)

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

why all that complex search syntax that doesn't work very often when all you have to do is add "code snippets" to the list of categories in the Advances Search box. Seems like such a simple solution to me.

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

It can't even find one of the code snippets I wrote

http://www.daniweb.com/search/search.php?q=transverse system directories&what=code snippets

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

tried that -- still doesn't work very well

http://www.daniweb.com/search/search.php?q=strcpy in code snippets

was replaced with
http://www.daniweb.com/search/search.php?q=strcpy%20in%20code%20snippets

and still only got threads in c and c++ board

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

Dani -- neither of those links work anymore. Have you changed the search engine because I don't see how to do advanced search any more to limit the search to a specific board.

But I did try your suggestion and entered "icon in c++" to get a list of all threads that discussed icons in the c++ board, and it displayed the threads I was looking for. So maybe the advanced search options aren't needed anymore.

Dave's suggestion doesn't seem to work: "strcpy in code snippets" or "code snippets strcpy" only gets threads in C++ and C boards. 20 pages of hits and I didn't read all of them.

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

First, SetName() is attempting to copy the name to an uninitialized pointer -- guarenteed to crash your program bigtime. Instead of using a char* for Name why not use the c++ std::string class so that you don't have to worry about memory allocation and all the problems that go along with it?

class Person
{
  protected:
    std::string Name;
  public:
    void SetName(std::stromg LastN)
    {
          Name = LastN;       
   }
};

You can also realize big improvements by using <vector> instead of array pointers, because vectors will auto expand to fit the desired array size, and you can index them just like you do normal arrays.

...
    vector<float> rawscores;
...
int main()
{
    vector<Contentent>  Players;
    ...
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is the selection sort algorithm. Compare it with yours. You are missing the swapping part at the end of the code snippet.

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

You are confusing characters positions with string positions. Your program is not sorting the string in the list array but attempting to sort the characters in just one of the strings. And it doesn't do that very well either.

1) go back and review the selection sort algorithm and compare it with what you have posted.

2) review your program requirements that you were assigned because I think you probably misunderstood it. Post it here if you want to.

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

In c++ you could use the fstream functions

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

This can't be your first class assignment -- by now you must have some clue about how to write a program and studied input and output file streams. Like any other program, start small, break it down to small parts that you can program. For example, begin by writing a program that prompts for the three things that are needed -- file name of input file, file name of output file, and amount of coal. Looks like you will have to construct your own input file, unless your instructor provided you one.