even with your slash (which I removed after running when I noticed it) didn't seem to throw anything off since it took it as an escape command and so \- only took up one space in the alphabet array...
Type: Posts; User: zmaker5
even with your slash (which I removed after running when I noticed it) didn't seem to throw anything off since it took it as an escape command and so \- only took up one space in the alphabet array...
ah thanks guys dunno why I didn't think to just make an array for the returns, but now I'm having a little problem, I'm trying to add a fix or de-"glitching" function that compares a spot versus its...
that's what I mean, does the return halt the switch and pull the program out of the function?
switch(1)
return 1;
switch(2)
return 2;
will that work is what I'm double checking, I'll...
with a switch though will return break or will I need return than break. I know return is supposed to exit the function but I haven't used switches in functions yet so I just wanted to make sure.
well I managed to pull this one off on my own, but I was wondering if for my conversion function a switch might be a better way of doing it.
The program takes a text file of 20x30 digits and...
ok it's working now
though could someone explain to me why changing it from i = 0 to i = 1 fixed it? thanks
#include <stdio.h>
#include <stdlib.h>
#define MAX 100
int main(void)
{
ok new problem, now all it does is print out the first line of any file minus the first character, no matter what is input for lines
new code
#include <stdio.h>
#include <stdlib.h>
#define...
alright I've got the program relatively working in terminal, part of the problem was fgets was grabbing the \n at the end of entry (dunno why I keep forgetting about that)
thanks for your help guys
ok changed to
#include <stdio.h>
#include <stdlib.h>
#define MAX 100
int main(void)
{
int i = 0, line, check;
yeah I change it to stdout and it works just the same (even if I test with fake file names with stdin and stdout.)
I originally was going to use a for loop and then thought a while loop would be...
fgets(words, 100, fp) is supposed to fill it, but since it only reaches that after EOF it's not going to put anything.
I have even changed the code to
#include <stdio.h>
#include <stdlib.h>...
I've also tried changing the if(check == '\n') to
if(check == '\0')
if(check == '\r')
if(check == ' ')
if(check == 32)
if(check == 't')
and still no change
Enter a filename, enter a number, and the program is supposed to get to that "line" and print it then exit. My plan to accomplish this was count newlines (i < lines) or until EOF and then print a...
that fixed it thanks, I figured that an EOF would always come right after a \n or \0 etc. bad assumption I guess. Thanks again guys
my C book says macintosh saves text files with \r at the end of lines (granted the book is old so maybe in OS X they may have changed it) and the 1000 MAX shouldn't be a problem since both files...
So I run this in the terminal, give it two filenames and I get a segmentation error, basically it's supposed to open two files, and print a line from file1 then print a line from file2 until an EOF. ...
doh! right because it's a pointer it's already an address, thanks
ok so I'm refreshing myself on pointers real quick, I thought I could directly pass the address of a variable to a function and not have to pass it a pointer, am I wrong? But the only way I've...
aye I had it working with "q" for ending and such, just the exercise I'm doing called for EOF, I guess so later maybe it will want me to convert the program to work with files not sure. But I assume...
mmmk added that in and declared a char c, resulted in
[Session started at 2007-07-29 17:23:10 -0400.]
Input up to 1000 characters
afafas
fasf
asfas
(entered an EOF...
I'm not sure what you're asking, it skips right down to invalid input before even doing a scanf (far as I can tell) and also I'm running this with stdin instead of from a file so maybe it's grabbing...
-just fixed that- sorry forgot to show that correction, I noticed that when I was typing up the thread and forgot to fix it in the post after fixing it in my file. That was causing quitting but not...
Ok this seems fine except once it reaches the switch it prints "invalid input" before anything had been entered and just sits there, doing nothing no matter what is entered.
basically just...
if (strcmp("\0", ptr) == 0)
printf("\n%s not found in %s\n", ins, fit);
else
printf("\n%s found in %s ||\t %c %p\n - - - - - -\n", fit, ins, ptr, ptr);
Right here are the two...
ok I get what you're saying, and the -1 won't be dangerous if I use a few if statements after string_in is called, but still why is it crashing when I leave in the "if ptr is null" section?