tags:

views:

86

answers:

2

Hey guys,

My program is meant to parse through a text file, extract relevant data and then save it in a SQL table. I compile it like so..

  gcc -o parse parse.c -I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient_r

then I run it like so...

  ./parse > tweets.rss

But it just hangs. it doesn't print any printf's I put in to debug. Whats wrong? here is my code...

http://pastebin.com/3R45zyMp

I'd appreciate any help!

+8  A: 

You are specifying that it should write to tweets.rss instead of read from it. Since your program reads from STDIN as the first thing it does and you don't supply any input, why would you expect any output?

Try:

./parse < tweets.rss
tvanfosson
Thanks, that got the file started but it doesn't go inside the loops :S any idea why?
Ulkmun
tvanfosson
+5  A: 

The following is going to loop for ever.

while(c!= ' ' || c != '\t' || c != '\n' || c != '>'){
    c = getchar(); //Get a new char
    test[i] = c;
    i++;
}

c can only be equal to one of them, so the condition will always be true.

Dipstick
+1 `c` can't be equal to all of those characters at the same time so that when one of the subconditions is false, the others are necessarily true making the entire expression true.
tvanfosson