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

There is no such animal as a NULL integer in either C or C++ languages to indicate that the integer has no value. There are languages that have that concept, but not in C or C++. C compilers will often produce either warnings or errors if you try to assign NULL to an integer because NULL may be defined as (void *)0 which is a pointer.

As previously mentioned C and C++ compilers initialize global variableds to 0. Other variables are left uninitialized so your program has to initialize them.

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

show us how you called make_list() from main().

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

I'm trying to get you to tell us what the program is supposed to do. Don't tell me to look at the code because the code must be wrong. If the code were right you would not be asking questions about it.

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

Also tell us the purpose of the program, what its supposed to do. AFAIK the program is supposed to count the number of cats that fall from the sky when "its raining cats and dogs".

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

The photo is a fake. Anyone with half a brain can use photoshop to do that.

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

Its more likely humanity will die out due to our own carelessness than due to nature. Baring some freak of nature like an asteriod collision, a global nuclear war is the most likely way we will become extince.

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

Well, I can patch MS-Windows too by writing device drivers and windows services. I can even hook into existing Microsoft code and change its behavior.

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

I think you will find all the installed services in the registry
HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services

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

The earth will end in fire. Everyone now knows that our Sun will exhaust all energy and go super nova some day, and when that happens the Earth and all other planets will burn to a crisp.

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

line 56 is wrong because the linked list is initialied to NULL every time that function is entered. What you have to do is pass variable start from main() as a parameter into make_list(), like this (Note the double asterisk, or double pointer).

struct queue_node *make_list(struct queue_node** start)
{
  char buffer[11];
  struct queue_node * current, * new;
  int j;
  for (j=0;j<2;j++)
  {
     new = add_node();
     if (*start==NULL)
     {
        *start = new;
     }
     else 
     {
         // locate end of linked list
         current = *start;
         while( current->next != NULL)
            current = current->next;
         current->next = new;
     }
     accept_input (new, buffer );
  }
  printf("%s<current>", current->word);
  printf("%s<start>", start->word);
  return start;
}
nadleeh commented: :) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster


I still don't understand why my cmd closes in this manner, though. :(

On my campus computers, the window always remains open until I 'press any key to continue.'

Why would my PC be any different? Is there a setting I can change to make VS always leave the window open?


*I AM using ctrl + F5 BTW, to start w/o debug*


EDIT: 'theLamb' I still haven't had time yet to fully digest the link you posted, but that looks like a pretty neat solution, so thankyou.

The difference may be the compiler you are using. Are you using the same IDE/compiler on your home PC that you are using at school?

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

Microsoft issues kernel patches all the time. Next.

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

The code you originally posted was pretty close to what you need. I just took what you had posted and expanded on it a little bit.

About that else statement where the value in array1 is the same in array2. If you want duplicates in array3 then copy the value from both array1 and array2 into array3. But if you don't want duplicates then copy from just one of those two arrays. If array3 does not contain duplicates, then the number of elements in array3 will not be the same as the sum of the number of elements in array1+array2, and in that case your program will have to keep track of the number of valid entries in array3.

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

Yes, there are a couple bugs in that code. For example, lines 23 and 24. You need to do that for both arrays. The other bug is on line 17 -- you have to copy the element from both arrays into the destination array. When array1 and array2 have duplicate values you will get two entries in array3 with the same value.

You might want to check for < on lines 5 and 10 instead of >.

If this is a school assignment I'm not going to post the final version because I'm not supposed to do your homework for you.

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

In the old days of MS-DOS that was pretty easy -- the program just kept track of which ports were in use. My MS-DOS program had up to 40 comm ports. You can still use that approach but also have to be aware that other processes may open a port. So if CreateFile() fails to open the port then your program must assume that the port is in use by some other process. I haven't used multi-port boards on MS-Windows operating systems, but I assume the manufacturer supplies a device driver, and you will have to read their documentation for details on how to use it.

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

Yeah, so? You compile C-version-6 with the compiler C-version-5 and you have an updated compiler.

And that's the Chick & Egg dilemma. What did K&R use the build the first C compiler (see the answer here)?

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

m a bit confused...how can it b written in C coz again u will need a C compiler to compile it..
also if it is written in assembly..then how can the code run on different machines..i mean,assembly language would be different for different architectures,won't it..??

printf() is not a built-in function, but instead it is a library function, and all library functions are compiled with the C compiler. C compilers do not have any built-in "functions".

How library functions are written is up to whoever wrote the compiler, or is implementation dependent. Microsoft may write it in C language, but Borland might write it in assembly. Microsoft has actually done it both ways with various compilers.

Its true that assembly language functions restrict their use to only one architecture. Such fucntions have to be completly rewritten to port to others.

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

mkdir() will create a directory. google for mkdir() to get more information.

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

line 7 is not calling a function. You have to put () after the function name, such as day_menu(). You will also want to put something just before the return in main() (such as getchar()) to make the program stop so that you can see what is on the screen. If you don't the os will probably erase the screen immediately after the program has ended.

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

use Windows communications functions. You can't access the ports directly as you did in MS-DOS. Instead, you have to open the com port using CreateFile(), then set up the port parameters with SetCommConfig(). After that you use ReadFile() and WriteFile() to read and write to the com port. For ReadFile() I put that in another thread so that it doesn't block the entire program.

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

how will you do what? Just setting them with = will copy the structure.

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

>>array3[k] = array2[e].ave;
Wrong. See the code I posted for the correct line. I assume you have two arrays of structures, so when a copy is needed you have to copy the entire structure, not just the value of one of its members.

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

I think what you want is this: assumes number elements in array1 is the same as in array2

int k = 0;
int n = NumberElementsInArray1;
for(int i = 0; i < n; i++, k++)
{
   if( array1[d].ave > array2[e].ave )
   {
      array3[k] = array1[d];
      d++;
   }
   else if( array2[e].ave > array1[d].ave )
   {
      array3[k] = array2[e];
      e++;
   }
   else // both are the same value
   {
      array3[k] = array2[e];
      d++;
      e++;
   }
}
// finish up array2
while( e < NumberElementsInArray1)
   array3[k++] = array2[e++];
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Well, then what is the point of being NULL? Why set it to zero?

In c++ NULL is just a macro (see this link if you don't know what a macro is) that is defined to be 0. Normally NULL is used to initialize pointers to a known address so that the pointer is never confused with some valid address. NULL means nothing at all when used with integers because 0 is a valid integer value. So it makes no sense to assign NULL to an integer. c and c++ languages do not have any way to tell us that an integer is uninitialized, or has no value at all.

iamcreasy commented: Awesome, exactly what I was looking for. +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>string db 4,?,dup('$')

I think that should be string db 4,?,4 dup('$') The first 4 is what is stored in the first byte, the ? says the second byte just contains whatever is already in the storage location, then the 4 dup('$') says to create 4 more bytes and fill each one with '$' character. If you want to enter more than 4 characters then replace 4 dup('$') with the number of characters you want to enter plus one more for the '\n' enter key. I would add another 2 or 3 bytes for good measure.

See this link on how to declare variables in assembly language

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

If you look at this link you will see that the first two bytes of the input buffer contain the buffer size followed by the number of characters in the buffer when the interrupt returns. You have to declare the buffer to be at least three bytes larger than the number of characters you want the user to enter, more is better just in case the user decides to enter more than what you are expecting.

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

No change necessary, other than possibly changing the data source in the connection string.

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

why? No one in his/her right mind would want to manually convert that to assembly.

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

The same way you access any of the Microsoft win32 api functions. This is c++ forum, not vb.

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

If you can't use std::string then you can use char. I thought you had to count the words too, but maybe not so I may have made your program more complicated than it needs to be.

Read a word, call strlen() to find out how long the word is. If the word is between 3 and 6 characters then write it out to an output file.

char word[8]; // assumes words are no larger than 8 characters
while( FileIn >> word )
{
   // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem with it under Web Development that everyone assumes that's the only purpose for databases. It isn't. Maybe it would be more logical and useful for it to be under Software Development.

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

Someone has made changes. The problem was that we had to put two blank lines after the close tag in order to get just one blank line displayed. This is a line This should be on the next line, but isn't. I remember someone reporting this a long long time ago -- must have gotton lost in all the work you have been doing over the last year or so.

Now if I have a multiple-line code to post in icode tags it works

Line 1
Line 2

This is on the correct line.

I guess the change I referred to was on multi-line text between icode tags.

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

its still an integer -- you can not enter decimals because cin will just ignore them. So 7.0 is the same as 7.1 as far as cin is concerned.

How to correct that problem? Change all ints to floats. Then the if statements starting on line 79 will not have to be changed because PHLEVEL will be a float.

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

Glad to see you are working on the spacing problem with icode tags. Now we don't have to add those extra blank lines after the [/icode] tag.

Good work :)

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

There is no "general" way to do it because it is operating system specific. C and C++ do not themselves have direct support for keyboards and mice.

You could use ncurses which has been ported to both MS-DOS and *nix (there is not MS-Windows gui version of it).

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

Read the file a word at a time instead of a character at a time.

std::string word
while( FileIn >> word )
{
   // blabla
}

Then if the word is 3-6 characters add it to a list with a counter for the number of times that word appeared in the file. There are a couple of ways to do it -- one way is to use <map>, that that may be more than you know how to do at the present time. The other way us to use an array of structures.

struct words
{
    std::string word;
    int count;
};

Well, there is a third alternative and that is to use two arrays, one string and the other count

std::string words[255];
int count[255] = {0};

However you decide to do it you will have to search the array to see if the word just read is already in the array. If it is, just increment the count for that word. If not then add the word to the array.

When all that is done then you are ready to write all those words and their respective counts to the output data file.

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

I doubt he really cares after 4 years.

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

All the if statements starting on line 79 are wrong. Why? Because PHLEVEL is an integer, therefore by definition it does not have decimals. PHLEVEL is not a real number (float or double). Those lines are also badly formed -- they need to be like this: if( PHLEVEL >= 0 && PHLEVEL <= 3) lines 61 and 62 will do nothing because you never print the value of computephlevel().

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

call strcat() from string.h header file. But be careful -- the desgination character array has to be large enough to hold both strings, and it can not be a pointer into read-only memory (e.g. string literals).

char boy[] = "Harry";
char* boy = "Harry"; // <<<< this is also wrong because its a string literal
char girl[] = "Mary";

The above can not be concantinated because boy is not large enough to hold b oth boy and girl.

The correct solution is like this

char boy[80] = "Harry";
char girl[] = "Mary";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>When I run the program and enter the value for cSalary the program just closes
You have to put something at the end of main() to prevent that from happening. One way to do that is to add a line cin.get() before main() returns. Programs execute the lines from top down, that is, it first executes line 1, then 2, then 3, etc. That means you can not put the calculations before the value of the variables are known to the program. For example, the value of cSalary is initialized to 0 on the first line, so the value of raise is cSalary * 0.05 which is raise = 0 * 0.05 = 0. Then on the very next line you have nSalary = cSalary. Since the value of cSalary is 0 (from the previous line) the value of nSalary will also be 0.

To fix that problem you have to put the calculations in the order in which you want them executed.

start of loop (do this 3 times)
   display current salary
   increment salary by 5% (e.g. salary = salary + (salary * 0.05);
end of loop
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Ads in my profile are disabled. I have IE8 ad blocker turned on. I added DaniWeb as one of the sites to allow popup ads, but that didn't help. Also enabled advertisements in my profile and that didn't solve it either.

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

You're never too old to watch cartoons :) Sometimes I like to watch Scooby-Do and Bugs Bunny. And Ratatoulille was hiralious

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

>>Some guessed placement of while loops did not help.

Then you did it wrong. Go back and try it again.

start of infinite loop
   listen for connection
   create thread to service connection
   back to beginning of loop
end of loop
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try disabling any anti-virus software you may have running.

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

It isn't necessary to typecast total because total was declared as an int

I would line up all the else's and reverse the order of the tests

if( total < 60)
    printf("You are failing with a %d percent \n\n", (int) total);
else if( total < 70)
    printf("%c---------||-----%d Percent\n\n", gradeLetters[3], total);
else if( total < 80)
<etc. etc.>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Nice info, but 4 years too late.

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

Sorry about that -- replace cout with printf(). The code for CreateProcess() is the same in both C and C++.

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

Well, maybe its something on my end then. Right now it says "Waiting for http://www.daniweb.com/community-center/daniweb-community-feedback/threads/353042/1500595#post5150C"

It's not a big deal, just a little annoying. Doesn't cause any other problems.

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

See the red arrow on the screenshot. This only happens in DaniWeb threads, nowhere else. The browser IE8 seems to always be waiting for something.