Forum: C Apr 25th, 2007 |
| Replies: 17 Views: 18,076 >>print the numbers in order?
First you need to specify what order you are going to print them in and then where you are going to print them. If you want to print them to file in ascending value... |
Forum: C Apr 5th, 2007 |
| Replies: 4 Views: 3,338 I see Ancient Dragon has typed faster than I and with a more precise version of what to do. As a learning experience here's a sampling of ideas I have about your code:
1) use int main(), not void... |
Forum: C Apr 1st, 2007 |
| Replies: 10 Views: 8,980 According to the instructions you posted you should have a pop() function. To delete the stack you will probably use a loop to repeated call the pop() function until the stack is empty. |
Forum: C Apr 1st, 2007 |
| Replies: 10 Views: 8,980 Uck! The loop you had in main() works fine for pushing one char at a time on to the stack from within main(). push_string is completely different than that in that the pushing needs to be done from... |
Forum: C Apr 1st, 2007 |
| Replies: 10 Views: 8,980 push_string() could use a for loop like you have in main() in push_string().
You are basing your stack on a list and adding each new node to the front of the list, which is fine. However, the... |
Forum: C Mar 17th, 2007 |
| Replies: 8 Views: 4,840 You're doing a shallow copy of array to array2. When you free the memory for array you also loose the memory you were pointing to in array2. Do a deep copy of array to array2 by assigning... |
Forum: C Mar 9th, 2007 |
| Replies: 49 Views: 10,496 Without comments it's difficult to say for sure what you intended. I have commented on the code you posted based on what I think you are trying to do. If I am correct, then there is a logic error... |
Forum: C Mar 5th, 2007 |
| Replies: 49 Views: 10,496 >>why are we defining elements
By that I assume you mean why intialize elements to some default value. Assuming that is correct, the answer is: when you declare an array none of the elements are... |
Forum: C Feb 27th, 2007 |
| Replies: 22 Views: 4,288 >>char *rstring;
This is not a string. It is a pointer to type char. In order to use rstring as a string you need to give it some memory. The segmenation fault comes when trying to use rstring... |
Forum: C Jan 27th, 2007 |
| Replies: 6 Views: 1,416 When including iostream I expected to see cout and cin rather than printf() and scanf() which I always thought were defined in cstdio (or stdio.h if you have an old compiler).
I also don't see... |
Forum: C Dec 9th, 2006 |
| Replies: 31 Views: 7,145 Note, strcmp returns 0, less than 0 or greater than 0. It doesn't necessarily return -1 if the first parameter is less than the second. It may return -3 or -111, who knows. It will be less than 0,... |
Forum: C Dec 3rd, 2006 |
| Replies: 31 Views: 7,145 Yes I should have writtten:
cout << wordArr[0];
instead of
cout << wordArr[i];
In looking at your attempt to work through WaltP's approach I notice you try to compare two C style strings... |
Forum: C Dec 3rd, 2006 |
| Replies: 31 Views: 7,145 In boolean logic false is assigned the integer value of zero and true is any other nonzero integer value.
strcmp() returns zero if the two strings are equal, less than zero if the first string is... |
Forum: C Dec 2nd, 2006 |
| Replies: 31 Views: 7,145 >>Was I correct that I had to add the '\0'to the end of the word so that it would be correctly terminated?
No, cin >> automatically null terminates input from either the keyboard or antother... |
Forum: C Nov 29th, 2006 |
| Replies: 10 Views: 4,088 For practical purposes if w is declared as
char w[1000];
then w can only hold 1 string. If you want w to be an array of strings, then you want this:
char w[x][y];
or one of these: |
Forum: C Nov 27th, 2006 |
| Replies: 31 Views: 7,145 Hope something in here meets your needs and helps you understand the syntax.
char * wordArr[10];
means wordArr is an array of 10 char pointers, not that wordArray is a pointer to 10 char... |
Forum: C Nov 22nd, 2006 |
| Replies: 15 Views: 3,073 Again I ask if it is necessary to create the Media class as abstract.? It is a compile time error to try to instantiate an object of an abstract data type.
struct A
{
int data;
virtual... |
Forum: C Nov 21st, 2006 |
| Replies: 15 Views: 3,073 Unless my memory is as cloudy as the weather this morning, you can't declare objects of an abstract class. Therefore, the Entry class could not have member variables of an abstract class type,... |
Forum: C Nov 20th, 2006 |
| Replies: 15 Views: 3,073 Thanks for the code tags, but use of indentation would make the code a whole lot easier to read!
Per your instructions the copy contstructor in your third post looks appropriate, though you'll... |
Forum: C Nov 17th, 2006 |
| Replies: 34 Views: 6,290 that can get tedious
Sure it can. But so can keeping track of where the file pointer is and what state is in. Just passing the file pointer to the file doesn't gaurantee the file pointer is in... |
Forum: C Jul 28th, 2006 |
| Replies: 16 Views: 2,326 The mechanism to create the string (word) frequency counter depends on your project requirements and your current knowledcge base.
If you know the number of unique strings that can be associated... |
Forum: C Jun 29th, 2006 |
| Replies: 10 Views: 2,649 I don't do much in the way of I/O using C. However, this reference:
http://www.cppreference.com/
indicates that
"rb+"
opens a binary file for read/write operations. |
Forum: C Apr 2nd, 2006 |
| Replies: 25 Views: 9,600 One way would be to:
accept input as a string.
convert string into an int
convert int into a char (or cast int into a char if all you want to do is display it) |
Forum: C Aug 15th, 2005 |
| Replies: 10 Views: 2,912 >the program should print the output as
12 is a number.
You don't need to convert the string 12 to the number 12 at this stage according the the directions given above. You will need to convert... |