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

Is that a MS-Windows GUI program? If it is, then you need to add a message pump in the loop so that Windows has a chance to update the window. I would put it inside that wait function.

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

probably the easiest way is to sort both arrays then all you have to do is check then from top to bottom, if any of the elements in array A are not the same as the corresponding element in array B then they are different.

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

std::vector is not a difficult class to use

class Person
{
   // blabla
};

vector<Person> theList;

// add a person to the list
Person p;
// fill out the structure is not shown here

theList.push_back(p); // add to the list

// after that you can use the vector just like any other array
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Great! start typing :) And welcome to DaniWeb.

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

I have a good friend I've known for 20 years who is from India and I still can't pronounce is name correctly! It doesn't seem to bother him because he never said anything about it, he probably just understands that it is a difficult name for Americans to pronounce.

My advice is not to let it bother you too much that we mispronounce your name.

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

zero -- I don't listen to music on the internet.

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

I think a name change would be a great idea :) John Doe or Bill Smith would be a good names to inherit.

>>and i wont feel like foreigner each time i am asked what my name is
But you are a foreigner. Technically we are all foreigners except the native American Indians.

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

Does the service program have permissions to do that? You might have to have the service log in with an administrator account.

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

[sarcasm]Ha Ha[/sarcasm] -- moved to Geek's Lounge because your post was not an introduction.

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

The post count on the forum's main menu is incorrect. For example the thread circled in the attached bitmap says 0, but there are three responses to the original post

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

This is going nowhere.

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

what programming language?

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

Just google for it. As I said before, there probably is no one URL that will give you the information you need for every type of IPC on every operating system. You have to narrow down your search a bit. Do you want information on named pipes, shared memory, shared files, or what? And what operating system -- MS_Windows, *nix, MAC, or something else ?

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

The problem is scoping -- object A goes out of scope before the cout statement on line 31. Delete the { and } on lines 20 and 29 and your program will work as you expect it to.

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

OMG what a resume!;) Welcome to DaniWeb, glad you are with us.

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

Highest() returns the wrong value -- it should return the index value (value of i loop counter) of the student with the highest grade. You will need to add another variable to keep track of that too.

There are a couple ways to implement those functions:

1) in main(), first call highest() and then pass its return value as another argument to print()

2) in print() add another ifstream argument, just before the last line of print() call highest() then print its return value.

outFile << "Student with the Highest score: " 
        << Highest(ifile, students) << endl;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

IPC isn't really all that difficult -- yes you can learn it on your own. *nix IPCs work differently than MS-Windows, and presumably other operating systems too.

IPC could be as simple as file sharing, or as difficult as sockets, pipes and shared memory. There are a lot of different ways for processes to communicate with each other. On MS-Windows every time you copy something to the clipboard and paste it into another program you are performing some sort of IPC.

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

you could do this:

void CMFC1Dlg::OnBnClickedButton1()
{
        char *ptr;
	if( m_POpened )
	{
		CString cmd;
		m_EditCmd.GetWindowTextA( cmd );
		m_Port.WriteToPort( (ptr = va( "%s%c", cmd, 13 )));
                delete[] ptr;
	}
}

or this:

const char* va( char* FormatStr, ... )
{
	va_list ArgPtr;
	static char FinalString[2048];
	va_start( ArgPtr, FormatStr );
	vsprintf_s( FinalString, sizeof(FinalString), FormatStr, ArgPtr );
	va_end( ArgPtr );
	return FinalString;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Stop your begging and read your text book. Also paying attention in class would help.

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

Oh God I completely forgot...

I should infract you for that! Quick, go to the store and buy a card and flowers.

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

If you want the comments stripped from the file then just redirect stdout to another file c:>myprogram.exe <test.cpp >newfile.cpp <Return>

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

memory is allocated on line 10 but never deleted. Try this:

void CMFC1Dlg::OnBnClickedButton1()
{
        char *ptr;
	if( m_POpened )
	{
		CString cmd;
		m_EditCmd.GetWindowTextA( cmd );
                ptr = va( "%s%c", cmd, 13 );
		m_Port.WriteToPort( ptr);
                delete[] ptr;
	}
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Wouldnt I be Able To Replace cin and cout with filestreams and remove comments from .c or .cpp files

Actuall you don't have to change a thing to make it get input from a data file instead of the keyboard -- just direct stdin from data file, like this: c:>myprogram.exe <test.cpp <Return> When the above is typed from a command prompt window your program will get input from the file test.cpp instead of the keyboard.

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

Oh, so all it does is strip comments from keyboard input and not from a *.c or *.cpp data file??? Why would you want to write such a program?


>>I mean this program exits when "x" is inputted. Is there any other way of Exiting?

Just press Ctrl+C.

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

>>What types of job positions are computer programmers needed for, Other than the obvious software development types?

I've had programming jobs at banks, accounting, manufacturing plants, government, and military. The most interesting ones to me were at the manufacturing plants, such as donuts, paper mills, tooth brushes, and jellybeans, just to mention a few. All those factories needed programmers to customize the computer software on assembly lines.

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

moved -- this thread is not an Introduction, like "Howdy folks, my name is Darrel and I'm happy to be here!". Nope. This thread seems to be a bitching session.

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

Happy Mother's Day to all you moms out there. :) ;) Us guys couldn't survive without you.

Narue on Mother's Day

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

Happy Birthday -- and welcome to the Old Fart's Club :)

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

what is all that crap??:icon_eek: And why is it in the c++ forum?

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

Thanks for that AD.
But, question... Does that mean my way is truly impossible?

No, its possible, just that its cumbersome because you will wind up duplicating the same code over and over and over for each type of linked list. Programmers try not to do that.

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

Now with the above functions it would be pretty simple to plug in the code for your restaurant program

struct restaurant
{
    restaurant() {number = 0;}
    restaurant(string nm, int n) {name = nm; number = n;}
    void SayHello() {cout << "Hello, I'm " << name << "\n"; }
    std::string GetName() {return name;}

    int number;
    std::string name;
    struct node* registers;

};

int main()
{
    struct node* head = NULL;
    int nRestaurants = 0;
    cout << "Enter the number of restaurants that you want\n";
    cin >> nRestaurants;
    cin.ignore();
    for(int i = 0; i < nRestaurants; i++)
    {
        stringstream str;
        str << "Wendy's #";
        str << i+1;
        string name = str.str();
        struct restaurant* item = new struct restaurant(name, i+1);
        InsertTail(&head, item);

    }

    struct node* n = head;
    while( n != NULL)
    {
        cout << ((struct restaurant *)n->data)->GetName() << "\n";
        n = n->next;
    }
    int number = 0;
    cout << "Which node to you want (1-5) ?\n";
    cin >> number;
    n = GetItem(head, number-1);
    ((struct restaurant *)n->data)->SayHello();

    DeleteList(&head);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

When programmers write complicated linked lists they do not duplicate all that code for every linked list. Instead they write the code once for general purpose lists so that the code can be re-used for any number of lists. Here is one example of how to write such a program, with test main() to exercise the functions

#include<iostream>
using namespace std;

struct node
{
    struct node* next;
    void* data;
};

struct node* InsertTail(struct node** head, void* data)
    // This function inserts a new node at the end 
    // of the linked list.
{
    // allocate memory for the new node
    struct node* item = new struct node;
    // initialize the node's variables
    item->next = NULL;
    item->data = data;
    // if this is the first time a node has been
    // added to the linked list then just set the
    // list head to the same address as the new node
    if( *head == NULL)
    {
        *head = item;
    }
    else
    {
        // There are other nodes in the list, 
        struct node* curr = *head;
        // find the last node in the list
        while( curr->next != NULL)
            curr = curr->next;
        // now insert the new node at the end
        curr->next = item;
    }
    return item;
}

struct node* InsertHead(struct node** head, void* data)
    // This function inserts a new node at the top 
    // of the linked list.
{
    // allocate memory for the new node
    struct node* item = new struct node;
    // initialize the node's variables
    item->next = …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sigh... but I feel that I'm close to finishing this.

Sorry, but you are not even close. You still have to do all those other linked lists, unless you have decided to simplify and redesign the program.

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

Try something like this:

char filename[20];
if(argc>1)
{
    filename = argv[1];
}

In your example you have to use strcpy() strcpy(filename, argv[1]);

tux4life commented: Everyone makes mistakes :) +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

when you type the filename on the command line that name (assuming it has no spaces) is contained in argv[1]

int main( int argc, char* argv[])
{
   if( argc > 1)
      cout << "The file name is: " << argv[1] << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If the program knows the HWND handle then call SetWindowLong() to hook into its default proc

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

Yes, function pointers might be helpful, but you would still have to have a list of pre-defined functions just as I had in the code I posted. For example if the command string were "say hello" the program could not call a function say() at run time unless it was already known at compile time.

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

where did you declare array item?

Change the while statement to while( i < sizeof(item)/sizeof(item[0]) && fscanf(...) > 0) . Note: if item array is a paremeter to the function you posted then that sizeof() stuff will not work.

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

something like this:

void foo( int x = 0)
{
   switch( x )
   {
       case 0:
           printf("case 0\n");
           break;
         case 1:
           printf("case 1\n");
           break;
        default:
           printf("default\n");
           break;
    }
}

int main()
{
    foo();
    foo(1);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I finally give up. BlackStar has not the slightest clue what he is doing -- just tossing together random pieces of code in the hopes that it will do something.

My suggestion to BlackStar is to just drop this course because its over your head anyway, then take a course in logic thinking. If you can't think at least a little bit logically then computer programming will be impossible for you.

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

I.T teach fixing computers

Ok, so you are taking a course in tech support ? No one can help you if you don't know what you want either. We are not mind readers.

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

On the client side, create a string that contains all the values separated by a space. Then send that string to the server. On server side, convert the string to individual data values, make the computations, then create a string with the result value and send back to the client.

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

Welcome to DaniWeb. Be sure to post your resume here to get more exposure.

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

No i don't need help all the time! I just thought some one that has been in this predicament before knows how i feel and would like to help and not make fun of is it a crime to ask for help! I am an Electrician I bet if i ask you some think about electrical wiring on how to run a ring main with a fuse spur. you would have to come to some one like me to ask hence i was just asking this forum for a little compassion!

No one is trying to make fun of you, we have all been in your shoes at one time or another. As for your electrical comment: I'd hire an electrician to do it, wouldn't even attempt it myself because I'd just burn the house down to the ground.

You still have not answered Narue's question: what course are you taking ? No one can help you at all here in this forum.

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

Welcome to DaniWeb.

>>But still I am confused for .net. What should i do?
Study. Practice. Poast in the C# forum.

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

I would create a structure like this:

struct data
{
    std::vector<string> items;
    std::string sortfield;
};

now create a vector of those items: vector<data> theList; Next read the file into the vector theList. Then you can easily sort the structures by any html tag you want, and finally write out the vectors back to a data file.

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

BlackStar is actually trying to create a very complicated linked list of linked lists (from another thread). These are lists within lists, and is the reason for the head and tail nodes within the Node structure. But unfortunately BlackStar has all that very confused.

Restaurant linked list
    cash register linked list
       customer linked list
          items_ordered linked list
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Box->tail -> next = Box;
Box -> tail = Box;

If you fail to see that the code above is just making all nodes point to the same Box node then you way over your head.

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

your test is wrong. Put this after the end of the code you posted.

node* node = Box;
while( node )
{
   cout << node->data << "\n";
   node = node->next;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read this article. You will probably want to write the code with VB Automation.

and an FAQ