Forum: C Jan 16th, 2007 |
| Replies: 5 Views: 1,921 never mind i figured out the problem(s) |
Forum: C Jan 16th, 2007 |
| Replies: 5 Views: 1,921 I'm almost finished with this program but the problem I'm having is with freeing the memory I allocated. Particularly in the area where I have pointers to strings.
#include <stdio.h>
#include... |
Forum: C Jan 16th, 2007 |
| Replies: 2 Views: 888 i've been trying to use fscanf to parse parts of a line from a file. The format of each line is like the following:
Connecticut,1788,Hartford,29
I've been trying to use this:
fscanf( fpIn,... |
Forum: C Nov 8th, 2006 |
| Replies: 2 Views: 2,237 yeah that's what I want, but how do you get the string after the semi-colon if there was no period at the end?
and why do you need a semi-colon after %[^;] |
Forum: C Nov 8th, 2006 |
| Replies: 2 Views: 2,237 I'm having trouble parsing a line with sscanf.
My line is:
1941 How Green Was My Valley; John Ford
and I want to separate it into a number, string, and another string. I tried:
if (... |
Forum: C Nov 6th, 2006 |
| Replies: 2 Views: 830 well the reason i was asking was that I can't get my BST to build correctly -- that is, the data inside doesn't display correctly :\
#include <stdio.h>
#include <stdlib.h>
#include <string.h>... |
Forum: C Nov 6th, 2006 |
| Replies: 2 Views: 830 I have the following declarations:
typedef struct{
int year; // key
char title[51];
char director[41];
} MOVIE;
typedef struct node{
struct node *left; |
Forum: C Aug 12th, 2006 |
| Replies: 7 Views: 9,333 ok, i read the website that ancient dragon posted up and it was pretty helpful. I managed to get the file copying function of my program to work :) |
Forum: C Aug 11th, 2006 |
| Replies: 7 Views: 9,333 How would I copy data from one file directly to another? I tried this syntax:
void disp_all(FILE *fp) {
FILE *ftemp = fopen("tempdata.dat", "wb");
fwrite(fp, sizeof(STOCK), 1, ftemp);... |
Forum: C Aug 11th, 2006 |
| Replies: 7 Views: 9,333 so you're allowed to change the state of the file by pointing the pointer elsewhere? |
Forum: C Aug 10th, 2006 |
| Replies: 7 Views: 9,333 One of the things I can't get working is reading and writing a structure to and from a file in binary. I'm sure that I'm using fread and fwrite correctly. However, I keep getting crashes which I... |
Forum: C Aug 10th, 2006 |
| Replies: 3 Views: 5,212 ok thanks guys. I think I had the correct answer :mrgreen: |
Forum: C Aug 5th, 2006 |
| Replies: 3 Views: 5,212 Hi. I can't a small part of this program to work correctly; the square root function either returns a bunch of funny symbols OR it returns 0.00
On a side note, I have 2 questions:
1) If you... |
Forum: C Jul 29th, 2006 |
| Replies: 5 Views: 2,340 :o
i made that fix but somehow i'm still getting garbage. <o/
wow, i didn't even think of that. |
Forum: C Jul 29th, 2006 |
| Replies: 5 Views: 2,340 Yes, this program is written in C.
data.txt:
838 758 113 515 51 627 10 419 212 86
749 767 84 60 225 543 89 183 137 566
966 978 495 311 367 54 31 145 882 736
524 505 394 102 851 67 754 653... |
Forum: C Jul 29th, 2006 |
| Replies: 5 Views: 2,340 This program is supposed to make two passes through a file; the first pass counts the number of elements inside the file to get the total size; the second pass will fill the array and sort it. The... |
Forum: C May 18th, 2006 |
| Replies: 3 Views: 10,861 I'm supposed to take user input in the form of a prefix expression, convert it to infix and postfix, and then print the results. So far, I've got both working, but I would like to add some... |
Forum: C May 15th, 2006 |
| Replies: 5 Views: 1,270 Oo that seems to make a bit more sense. Where did you get that quote btw? |
Forum: C May 14th, 2006 |
| Replies: 5 Views: 1,270 No that's not what I meant. I'm supposed to change an inorder traversal into the original binary tree and then produce a level order traversal. Sorry for any misunderstanding. |
Forum: C May 12th, 2006 |
| Replies: 5 Views: 1,270 OK.......right now i'm learning about binary tree traversal and this problem looks like a total killer to me. Here's it is:
Write a program that takes as input the preorder and inorder traversals... |
Forum: C May 2nd, 2006 |
| Replies: 1 Views: 1,224 Currently, I've been reading about Dynamic Programming in this book and I don't really see the difference between bottom-up dynamic programming and top-down dynamic programming. It seems like both... |
Forum: C Apr 28th, 2006 |
| Replies: 10 Views: 2,260 Well i'm trying to learn recursion from this Algorithm book (Algorithms in C by Robert Sedgewick) and the author jumps from factorial recursion to a recursive program to evaluate prefix expressions... |
Forum: C Apr 27th, 2006 |
| Replies: 10 Views: 2,260 i is automatically initialized to 0 if its external. Also that looks like the factorial program that's pretty much everywhere =\ |
Forum: C Apr 26th, 2006 |
| Replies: 10 Views: 2,260 OK..I went through a couple of C books and some webpages to do some simple excersizes on recursion and I understand it a little better now. SoOoOo, here's my program which is only slightly modified... |
Forum: C Apr 25th, 2006 |
| Replies: 10 Views: 2,260 heheee yes your definition calls itself.
i'm gonna give this another shot ;p |
Forum: C Apr 24th, 2006 |
| Replies: 10 Views: 2,260 This problem is asking me to convert an infix expression to a postfix expression using recursion. I did the exact same problem using stacks (w/o recursion), which was much easier, but on this one, I... |
Forum: C Apr 20th, 2006 |
| Replies: 2 Views: 1,149 OHH OK TY ty ty that makes much sense now ^_^V |
Forum: C Apr 20th, 2006 |
| Replies: 2 Views: 1,149 I'm kind of confused about how the modulus operator works.
Suppose i have x % y with x > y. So if x was 6 and y was 2, then 6 % 2 would produce 0.
But i don't really get what happens when x... |
Forum: C Apr 20th, 2006 |
| Replies: 11 Views: 1,887 Thanks......your program looks organized but complicated :eek: |
Forum: C Apr 19th, 2006 |
| Replies: 11 Views: 1,887 I understand the the Postfix notation and the stack concept.
It's just that this problem is asking me to use a stack of operators o_O for some reason that I shall figure out later....
And... |
Forum: C Apr 18th, 2006 |
| Replies: 11 Views: 1,887 I forgot to consider double(or more) digit numbers in this stack program.
I also figured out where the problem was and applied a really cheesy way to get around it which uses the atoi function ... |
Forum: C Apr 17th, 2006 |
| Replies: 11 Views: 1,887 Thanks for the reply.
Sorry, I didn't make this clear before, but my input is to take in a single string of equations (in postfix form) with no spaces. I don't think the problem lies with scanf... |
Forum: C Apr 17th, 2006 |
| Replies: 11 Views: 1,887 From what I read in a few books, a static variable retains its value(s) throughout the lifetime of a program.
In this stack program I've been trying to fix up, the static var doesn't seem to... |
Forum: C Apr 13th, 2006 |
| Replies: 3 Views: 10,030 i'm sorry i meant if x < y. |
Forum: C Apr 13th, 2006 |
| Replies: 3 Views: 10,030 Hmm I was lookin through a recursion program in this book i have here and the only thing I'm having trouble with is the modulus operator.
I know that it returns the remainder of 2 numbers.
But,... |
Forum: C Apr 5th, 2006 |
| Replies: 10 Views: 2,620 So, after each node is created and linked with other nodes, the links in each node will be pointing to the next one no matter what?
I stepped through the debugger after reading your post and each... |
Forum: C Apr 5th, 2006 |
| Replies: 10 Views: 2,620 I think I addressed the question incorrectly and I failed to mention that this was a circular linked list.
After the list is generated (a circular list with 9 numbers) and there is a link between... |
Forum: C Apr 4th, 2006 |
| Replies: 10 Views: 2,620 I wrote a program up with linked lists that creates a circular list containing 9 nodes. Each node contains a number (ranging from 1-9) as an item.
My question is...in the while loops, how does... |
Forum: C Apr 4th, 2006 |
| Replies: 4 Views: 4,343 well nevermind i figured out the first part of the question that i had.
my next question has to do with changing the contents of the array of structures. How do I keep the original items from... |
Forum: C Apr 3rd, 2006 |
| Replies: 4 Views: 4,343 How do I make selection sort work with strings in a structure?? My compiler doesn't seem to like my variable assignments under the show_alpha() function. :cry:
#include <stdio.h>
#include... |