Search Results

Showing results 1 to 40 of 159
Search took 0.02 seconds.
Search: Posts Made By: Lerner ; Forum: C and child forums
Forum: C May 22nd, 2009
Replies: 9
Views: 465
Posted By Lerner
It's not that we've forgotten what it's like to be a newbie. Quite the contrary. I suspect all of us could relate any number of stories about advancing on the learning curve. It's just that this...
Forum: C Apr 20th, 2009
Replies: 6
Views: 299
Posted By Lerner
Use of code tags around your posts will get you more responses than if you don't use them. The use of code tags is discussed in the watermark of the Message box as well as in the Announcements...
Forum: C Apr 27th, 2007
Replies: 2
Views: 914
Posted By Lerner
I think this will work. Let's change it up a bit. Say I put some numbers in a paper bag, gave you the paper bag and said take the numbers and tell me what the biggest and smallest number in the bag...
Forum: C Apr 25th, 2007
Replies: 17
Views: 17,873
Posted By Lerner
>>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 23rd, 2007
Replies: 10
Views: 2,229
Posted By Lerner
I have no idea what the Lee algorhithm is, or isn't. However, given your description and your post, I presume you could do something like this.

The pattern presented can be considered as a series...
Forum: C Apr 19th, 2007
Replies: 8
Views: 2,380
Posted By Lerner
int a, b, c ; char colon ;
std::cin >> a >> colon >> b >> colon >> c ;

Don't have a compiler to test any code at the moment but I'd be concerned that cin will fail when trying to read the third...
Forum: C Apr 19th, 2007
Replies: 8
Views: 2,380
Posted By Lerner
three calls to getline() with the first two using : as delimeter and third using newline. Then convert each string obtained into numerical value using sprintf() or strtol() or atoi() or...
Forum: C Apr 19th, 2007
Replies: 5
Views: 1,498
Posted By Lerner
1) use code tags when posting code to the board
2) intialize cnt to 0 every time count() is called
3) it isn't polite to highjack someone elses thread. Though there is some similarity between your...
Forum: C Apr 19th, 2007
Replies: 2
Views: 1,066
Posted By Lerner
I'd use serial calls to getline to parse the file.

#1 read information up to = and ignore input
#2 read information up to : and save
#3 read information up to : and save
compare #2 and #3 and...
Forum: C Apr 17th, 2007
Replies: 10
Views: 1,620
Posted By Lerner
the baseline behavior of fgets() is that it will read in the newline char in addition to the alphanumeric char and other whitespace char if there's enough room in the array. So I here's what I would...
Forum: C Apr 14th, 2007
Replies: 2
Views: 675
Posted By Lerner
You could use the division and the modulo operators in sequence to generate indivual digits which could be used to increment counters in an an array of ints and then print out the array values with...
Forum: C Apr 13th, 2007
Replies: 5
Views: 3,988
Posted By Lerner
The program doesn't need it. In fact the program could care less. It's going to use 8 bytes or whatever of memory to store the double with as much precision as it can. Your teacher wants to see if...
Forum: C Apr 13th, 2007
Replies: 5
Views: 3,988
Posted By Lerner
Look up C output format specifiers. The number will be stored to whatever degree of precision that is allotted to type double, but the degree of precision can be dictated on displaying the value.
Forum: C Apr 9th, 2007
Replies: 3
Views: 1,030
Posted By Lerner
//set loop pointer to start of loop
loopPtr = listPtr;

//look at all nodes in list
while (loopPtr != NULL)
{
//if you find it
if(loopPtr-> item == Item)
//you can stop
...
Forum: C Apr 9th, 2007
Replies: 2
Views: 1,101
Posted By Lerner
Welcome to Daniweb!

I'm having trouble telling where option 1 and 2 separate and whether there is a third option. Your description however sounds pretty good. Some folks here would prefer to...
Forum: C Apr 5th, 2007
Replies: 4
Views: 3,324
Posted By Lerner
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 5th, 2007
Replies: 6
Views: 1,538
Posted By Lerner
Read the input into a string, not a numerical variable. Then validate the string. Once validated convert the string into a numerical variable.
Forum: C Apr 2nd, 2007
Replies: 29
Views: 3,394
Posted By Lerner
In the OPs recent posts he consistently does this:

for(i=0;i<=5;i++);{
for(j=0;j<=5;j++);{

Unfortunately the semicolon stops the loop before the opening braces become evaluated so they are...
Forum: C Apr 1st, 2007
Replies: 10
Solved: Stack in C
Views: 8,817
Posted By Lerner
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
Solved: Stack in C
Views: 8,817
Posted By Lerner
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: 2
Views: 1,305
Posted By Lerner
Target is declared as a string but you treat it as a single char in the call to scanf() and then you treat the single char as a string in strcmp. You similarly type mismatch single char for strings...
Forum: C Apr 1st, 2007
Replies: 10
Solved: Stack in C
Views: 8,817
Posted By Lerner
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 27th, 2007
Replies: 4
Views: 2,182
Posted By Lerner
A couple ways are:

1) include a flag within the data of each record indicating that this record is to be ignored and leave it within the file. Works nice if file storage isn't a concern

2) or...
Forum: C Mar 17th, 2007
Replies: 38
Views: 5,344
Posted By Lerner
Below is your code after the while loop in main() has completed. I have added comments and suggestions based on your previous posts.

/*
find maximum frequency within WordCounter
*/
Maxcount...
Forum: C Mar 17th, 2007
Replies: 8
Views: 4,777
Posted By Lerner
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 17th, 2007
Replies: 2
Views: 749
Posted By Lerner
You'll also need a variable to hold the current guess, a protocol to access each element in the char array and determine if it is equal to the current guess and a variable to keep track of how many...
Forum: C Mar 15th, 2007
Replies: 38
Views: 5,344
Posted By Lerner
>>I do not get how to show in ASCII order the words with equal frequency.

To continue the scenario from post #29, once you have the array of uniqueWords you can search allWords to determine the...
Forum: C Mar 13th, 2007
Replies: 38
Views: 5,344
Posted By Lerner
To do this without tables or lists you could maintain two different arrays: allWords to hold all the words read in from file in sequential order, and uniqueWords to hold all unique words found in the...
Forum: C Mar 13th, 2007
Replies: 2
Views: 4,339
Posted By Lerner
If the goal is to display the hexadecimal equivalent of a char on the screen using C++ I/O and you don't want to do all the conversions yourself, then options to atoi() and sprintf() with "%x" format...
Forum: C Mar 9th, 2007
Replies: 49
Views: 10,458
Posted By Lerner
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: 38
Views: 5,344
Posted By Lerner
Here's another approach that might work.

Use a list to hold the words and their frequency since you don't know how many words you will have and you are using C so STL vectors won't help. Each...
Forum: C Mar 5th, 2007
Replies: 49
Views: 10,458
Posted By Lerner
>>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 Mar 2nd, 2007
Replies: 8
Views: 2,007
Posted By Lerner
In theory, WaltPs approach could work too; the only problem is the file apparently doesn't indicate how many lines the puzzle will have, only that each line/row will be no longer than 30 char and...
Forum: C Mar 2nd, 2007
Replies: 8
Views: 2,007
Posted By Lerner
The first line of the file is apparently the number of words to find, in the case just posted, 3. Since the 3 is there I assume the file may have something other that 3 and you won't know until you...
Forum: C Mar 2nd, 2007
Replies: 8
Views: 2,007
Posted By Lerner
Evaluate the return value of the input function rather than the return value of eof() to regulate the loop. fscanf() returns the number of character read in or EOF if it fails and fgets() returns...
Forum: C Mar 1st, 2007
Replies: 8
Views: 2,007
Posted By Lerner
Not on topic:
1) it should be int main(), not void main().
2) don't use the return result of eof() as the conditional for a loop to run or not. Sooner or later it will get you into trouble.
...
Forum: C Feb 27th, 2007
Replies: 22
Views: 4,260
Posted By Lerner
>>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 Feb 21st, 2007
Replies: 11
Views: 2,983
Posted By Lerner
I'd either try commenting out the function call and rebuild/run the program to see if the error goes away or post the entire program, assuming it isn't too long, so somebody can try compiling it on...
Forum: C Feb 21st, 2007
Replies: 11
Views: 2,983
Posted By Lerner
>>Can the same function return the score to main to determine the winner?

Sure, either use the value of score as a return value, or pass score to the function as reference parameter type. You...
Forum: C Feb 21st, 2007
Replies: 11
Views: 2,983
Posted By Lerner
>>I checked the prototype and the definition but I'm not seeing it.

Please post function prototype and function call in addition to function definition.

>> Second I want store the score for...
Showing results 1 to 40 of 159

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC