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

>>mysql_result[3000][2]=msq_row;

If you programmed the rest of that then you should probably know that the above like doesn't work. You should be reading this tutorial. (scroll down to the section Retrieving data from the database)

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

I found another way to convert to lower case and wanted to see if you thought it would work. I have put it into my code as thus far I haven't found anything else that seems to work.

#include <algorithm>
.... //stuff happening then when user enters flavor,
std::string lowerCase = flavor;
std::transform(lowerCase.begin(), lowerCase.end(),
	lowerCase.begin(), ::tolower);

Why didn't you just convert flavor to lower case instead of creating yet another variable?

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

>>The changes you mentioned have been made except for changing ! == to !=. For some reason, my compiler is not liking !=. I get the error "ISO C++ forbids comparison between pointer & integer". I'm using Cygwin, if that helps.


Your compiler is correct -- I was thinking names was an array of std::string, not characters. use strcmp() instead if( strcmp(names[i], "z") != 0)

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

could be re-written like this: Notice you don't need || at all. And that function should only have a return statement at the end of the function, not on every line.

char grade;
    if(score < 60)
        grade = 'F';
    else if(score <= 69)
        grade =  'D';
    else if(score <= 79)
          grade =  'C';
    else if(score <= 89)
        grade =  'B';
    else
        grade = 'A';
   return grade;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't have to store all the lines, just the two lines that you want to compare. Sequentially read the file, counting lines as you go along then save only the two lines you want to compare.

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

line 7 and 8 of the read function: Line 8 is unnecessary because line 7 opens the file when the stream is declared.

line 12: if lastname never contains spaces then use use >> operator instead of getline().

line 13: doesn't make any sense. names is an array, but you are treating it as a simple string. And it is more common to use the != operator rather than ! and == as you have done. if( names[i] != "z") line 15: you are reading in 4 scores, but the array can only hold 3.

line 20: Where is sum initialized to 0? It needs to be done just before the loop starts on line 15.

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

c++ has std::string that is declared in <string> header file. google for std::string and you will find links that describe all its methods.

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

There are two problems on each of those lines
1) one, two, three, etc are not defined in that function.

2) char is a data type, but you failed to provide a variable name. For example char something = 1; [edit]What ^^^ said too :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
void swap(int* int1, int* int2)
{
    int temp = *int1;
    *int2 = *int1;
    *int1 = temp;
}


void sort(int int1, int int2, int int3)
{
if( int1 > int2)
{
   swap(&int1, &int2);
}
// now do something similar for the other integers
// Do NOT use else statements.
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Deposit $10,000.00 USD in my paypal account and I'll do it for you. Otherwise you will just have to write the program yourself.

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

>>The program was initially written in VC++

VC++ is not a computer language. Its an IDE/compiler. So saying you are converting from vc++ to c++ is nonsense.

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

better off replacing that fprintf() with c++ fstream class so that the compiler won't complain so much.

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

If you use string, then use find() to locate the space, and substr() to extract the characters from position 0 to the location returned by find().

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

delete line 56 -- it does nothing.

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

Why did you use fgets() instead of fscanf()? fgets() gets the entire line without regard to spaces, which is not what you want. Look at the simple code I posted, it does what you need. All you have to do in that loop is add the word to the linked list or increment the word's counter if its already in the list. There is no need for that is_separator function because fscanf() will take care of that for you.

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

You now have all the pieces you need, all you need to do now is put them together. In your original program, just delete lines 19-45 because they are not necessary. Then just write a simple for loop that displays the values of students and grades arrays, like the code Clinton already gave you.

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

@twomers

"The #include thing only works on compile time. Not run time" - so you mean the binary will have all the contents of the the included file???

Yes. Its not really all that big a deal since the program has reserved space for the data anyway. Even though you have the arrays declared in if statements the compiler will allocate memory for all of them at the same time somewhere in global memory (since they are declared static). The if statements just limit the scope of those arrays.

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

Is a core file produced? Yes, then use dbg on that core file and it will tell you where the crash occurred.

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

>>The program is supposed to take in a file provided through standard input
That means get the name of the file from standard input, not the lines of the file. You have to open the file and read each word, something like this:

int main(int argc, char* argv[])
{
   FILE* fp = fopen( argv[1], "r"); // open the text file
   char buf[255];
   while( fscanf(fp,"%s",buf) > 0) // get a word
   {
    // populate the linked list with this word
   }
}
fclose(fp);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Modern 32-bit compilers to not support that header file because it was intended for 16-bit MS-DOS 6.X and earlier operating systems. The alternative is to use win32 api functions OpenFile() to open a comm port, ReadFile() and WriteFile() to read/write to it. MSDN has a large article about serial communications.

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

@gerard4143 :
@Dave : The first example is working, the structure gets populated with values in the inc file.

Yes it does work.

Ok, if its not possible then is there any other way to populate this structure using the inc files without using #include?

Read the file into the array just like it was any other normal text file.

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

>>Is there anyway to achieve this?
No because the #inc lude directive is processed at compile time, not runtime.

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

Hummm -- asking us to do your homework???

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

First you need a 2d array to hold the final strings. Then a row counter, a column counter, and a comma counter. In a for loop copy each character in the original array into the current row/column of the 2d array. When the 3d comma is found, increment the row counter to start a new row in the 2d array, zero out the column counter, and zero out the comma counter.

char string_array[20][80] = {0};
    char seed_array[] = "a1,b2,c3,a2,b1,c2,a3,b2,c4,";
    printf ("seed real=> %s\n",seed_array);
    char *p=NULL;
    int i,j,k;
    int comma_count = 0;

    for(i = 0, j = 0,k = 0; seed_array[i] != '\0'; ++i)
    {
        string_array[j][k++] = seed_array[i];
        if( seed_array[i] == ',' )
        {
            ++comma_count;
            if(comma_count == 3)
            {
                ++j;
                k = 0;
                comma_count = 0;
            }
        }
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No. You can build windows gui programs, but you have to do it manually or buy someone else's program that produces windows resource files. You could also use a different IDE/compiler, such as QT which contains gui guilder.

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

Also, I have tried the tolower() function but the compiler will not accept it. Here is how I tried to code it:

flavor = tolower(flavor)

What did I miss?

tolower() only works on a single character, not the entire string.

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

line 21: >> getline (cin, flavor) >> flavor;
Remove the ">> flavor" at the end of that line.

You can not do switch statements on strings! switch only accepts integers. You will have to replace that switch statement with a series of if statements. Another way to do it is to change that menu so that you enter a number instead of a string

cout << "Welcome to Frozen Tongue Ice Cream Shop\n"<<endl;
	cout << "Please enter the flavor number of icecream sold or 'STOP' to exit.\n"<<endl;
	cout << "1.  Flavors avaliable:\n";
	cout << "2.  chocolate\n";
	cout << "3.  valnilla\n";
	cout << "4.  strawberry\n";
	cout << "5.  mint\n";
	cout << "6.  rocky road\n";
	cout << "7.  mocha\n";

Also note that you do not need both "\n" and endl because endl also causes '\n' -- leave it if you want your menu displayed with a blank line between menu items..

With the above menu you can enter a number instead of a string. Then change the data type of flavor to int.

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

what don't you understand -- you should start your own thread to ask a question.

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

sizeof( any pointer ) is always the same -- sizeof returns the number of bytes it takes to store the address of the pointer, not the length of the string the pointer references. So lines 12 and 13 of your code will always return the same value (probably 4).

line 14: you are attempting to store an unitialized pointer into the vector. undef points to just some random memory location, and that may cause a seg fault, especially if you later attempt to do anything with that pointer.

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

you are attempting to put code outside a function. Lines 7 and 8 have to be inside a function.

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

Well, if we want to talk about our ages -- I'm 66 and retired American Air Force (1985). Fortunately I survived View Nam with no injuries. But I would not presume so much as to use my age as am excuse for being an old grouch. Nor are old war injuries an excuse for being nasty here at DaniWeb.

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

I accept that some, or most, of my answrs have been done in haste but as an older generation person, my mind is not as sharp as some of you younger people. Also, being disabled, I'm unable to sometimes clarify the point I'm trying to make.

Oh so now your trying to blame it on your age and disabilities :D I don't see how either is relevent to your problems here.

lllllIllIlllI commented: Oh yeah, here at daniweb, its not often old people do a proper answer :P +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>See rather the Microsoft sample
What sample? Post link.

[edit] Probably this?

>>posted 10000 times on BBS & Usenet.
Probably -- now its been posted 10001 times :)

tux4life commented: Well said. +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>He seems to think he is a Moderator...is this true or is it all in his own head?
Does he have a moderator badge, like jbennet? If not then he is not a moderator at DaniWeb, but he could be somewhere else.

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

In its simplest form: g++ stock.cpp usestock.cpp -o myprogram <Enter> You can also install Code::Blocks which will let you easily create and compile multi-file projects.

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

This demonstrates how to get a list of your computer's logical drive letters under the MS-Windows operating system.

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

Here is the difference between Girlfriend 7.0 and Wife 1.0 operating systems (I've posted this before in geek's lounge)

O/T Dear Tech Support
Subject: Computer Hard and Software:
Dear Tech Support:
Last year I upgraded from Girlfriend 7.0 to Wife 1.0.
I soon noticed that the new program began unexpected child
processing that took up a lot of space and valuable resources.
In addition, Wife 1.0 installed itself into all other programs and
now monitors all other system>activity. Applications such as Beer
Night 10.3, Cricket 5.0, Hunting and Fishing 7.5, and Racing 3.6 no
longer run, crashing the system whenever selected.
I can't seem to keep Wife 1.0 in the background while attempting
to run my favorite applications. I'm thinking about going back to
Girlfriend 7.0, but the uninstall doesn't work on Wife 1.0. Please
help!
Thanks,
A Troubled User.
______________________________________
REPLY:
Dear Troubled User:
This is a very common problem that men complain about.
Many people upgrade from Girlfriend 7.0 to Wife 1.0, thinking that
it is just a Utilities and Entertainment program.
Wife 1.0 is an OPERATING SYSTEM and is designed by its Creator
to run EVERYTHING!!!
It is also impossible to delete Wife 1.0 and to return to Girlfriend
7.0. It is impossible to uninstall, or purge the program files from
the system once installed.
You cannot go back to …

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

Exactly, if the OP is satisfied that the problem has been resolved then there is no need for solvers to continue contributing to the thread. Marking the thread as solved means they can see from the forum page that the OP no longer needs help.

Although technically you are correct, sometimes it doesn't work like that. I've seen discussions continue even after the thread has been marked solved. And there is no rule to prevent it, for good reason. The op may be satisfied with the result but other contributors may want further discussions.

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

try this

In c++ I would use either <vector> or <list> c++ classes instead of creating your own linked list as you might do in C language.

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

Oh so you don't think *nix is not just a bunch of hacked together programs??? After I installed Ubuntu and Fedora 11 they both went to their respective web sites and downloaded updates. Even after that I couldn't get the sound to work right, but I found a tutorial that explained how to uninstall something (I forget what) then download something else. It was quite a lengthy tutorial -- but worked. Even after all that I still can not play movies that are on DVD, I understand that's because the drivers are not installed with the os.

I have Windows 7 Home Prem and everything worked perfectly after installing the os. Perfect sound, plays both blue-ray and normal DVD movies, youtube videos (with sound ;)

Now tell me who has the hacked operating system.:P

lllllIllIlllI commented: Hello new best friend :P +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The main reason parents don't want their minor-age kids to have sex is because sex between opposites produces babies. For a girl that will rune your life forever and ever. And guess who will get stuck with the job of raising the bastard kids? Yes, you got it -- your parents. So play it safe and keep your legs crossed so that you don't get pregnant.

Adamsappleone commented: Hello, just grabbed the first post I saw with you name on it to give you a recprocating rep. Thanks +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

please send me a small c program using file handling for banking without using garphics

to obtain a mini project in c using file handling without graphics

Don't be such a lazy ass and write them yourself.

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

Just installed 64-bit Windows 7 Home Premium. So far so good. I did a fresh install, reformatted the hard drive, and installed fresh.

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

win32 api doesn't work on non-Windows platforms, but this code snippet will work with some possible mods to the defines at the top.

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

After calling CreateProcess() call WaitForSingleObject(). When that returns then you can call GetExitCodeProcess()

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

If you are USA citizen or legal immigrant then join the US military. They will give you all the free training you will want. Most colleges and universities in USA have Cadet programs that let you attend college full time and give scholarships to help pay for tuition etc. I know medical doctors who got their medical degree free via military programs. Well, maybe not exactly "free" ... it cost them about 10 years of their life on active duty.

Rashakil Fol commented: lol :D +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

video of a drunk trying to buy some more beer.

Will Gresham commented: Brilliant +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't see any reason to have an icode button -- what's so difficult about just typing them in as you type? I don't use the code tag button either for the same reason. I can just type the tags by the time I have to remove my hands from the keyboard, find the mouse, move it to the button, click it, move the cursor between the two tags, move my right hand back to the keyboard, and begin typing again. All that's just too much effort.

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

>>I must use Fork() and Wait()
Why? Sounds like over complication of the problem.

>>myComd is an unallocated pointer which can not be used until you allocate memory to it. IMHO don't make it a pointer; remove the star and replace pointer notation "->" with dot notation "."

>> line 7: #define BUFFER_MAX (50)
Paths can be up to 255 characters.

>> line 26: strncpy(myCmd->name,
Again, you're program is scribbling all over memory because name is an unallocated pointer.

>> myCmd->argv[0] = strtok(NULL, " ");
Wrong. argv[0] must be the name of the program you want to execute -- it can also contain the path.