You're not including <string.h> for your str* functions and memset. Also, refer here for why using !feof(fp) in a loop is wrong.
Type: Posts; User: l0cke
You're not including <string.h> for your str* functions and memset. Also, refer here for why using !feof(fp) in a loop is wrong.
You can use chdir() to change directories. If you don't want to hardcode in the directory, you can have it take it in as an command line argument.
For *nix based systems you can use ncurses or curses. I'm not sure about Windows though.
You can google plenty of ncurses tutorials and you can check out the source code for rogue-like games.
printf("%u in octal is: %o\n", b, b); /* try this instead */
puts() also prints the new line character at the end for you. So you could type:
puts("hello world!");
instead of
printf("hello world!\n");
There is a bettter link in the post below.
You can use %u with scanf()/printf() to read/print an unsigned int(assuming you know a little bit about scanf()/printf()).
Your assignment is to print "Press any key!" INCLUDING the quotes.
printf("Press any key!\n"); /* outputs: Press any key! */
/* however */
printf("\"Press any key!\"\n"); /* outputs: "Press any...
Didn't know that snprint wasn't portable. I also figured that it's better to use to prevent a buffer overflow.
int num = 12345;
char string[6];
snprintf(string, 6 ,"%d", num);
i is set to the last index number + 1, that's why the return is return stack[--i], so it subtracts 1 from i before it returns it.
int top(void)
{
int i;
for(i = 0; stack[i] != '\0'; i++)
;
return stack[--i];
}
What is stack declared as? Is it an int, char, etc?
Could you specify the OS?
If it's a *nix based OS you could change the permissions on /dev/fd0(*BSD's floppy device) to not allow writing.
It's back to a readable size, thanks.
It's not the line length, it's the size of the font.
You forgot to remove the '\n' from fgets(). Some people will also say scanf() is bad to use, so I suggest to use fgets() again.
http://gcc.gnu.org/faq.html
http://gcc.gnu.org/readings.html
It's giving you that error because you're delcaring a variable inside the for loop, which is not part of the C99 standard(I think).
10257 -- 4
10258 -- 5
10257 -- 4
This should be:
10257 -- 9
10258 -- 6
10257 -- 4
(p + 1) will print the address of p[1], because you're incrementing where it points to, not what it points...
You forgot something:
printf("\"Press any key!\"\n");
Like \n, \"(that prints a ") is an escape sequence
if(10 = num)
If you do that, you will get an error at compile time. Which can save you from code that does unexpected things.
If(num = 10)
Will not give you a compile time error, which will not...
if((fp = fopen("&s" ,username, "r")) == NULL)
perror("%s" ,username);
fopen() only opens the file for reading, it doesn't do any reading itself. The arguments for fopen "&s", username will not do...
/* proper use for fopen */
FILE *fp; /* file descriptor */
if((fp = fopen("passwordfile.txt", "r")) == NULL) /* open for path for reading, check for errors */
perror("passwordfile.txt"), exit(1);...
You're also using the wrong syntax for fgets and fopen. I don't see any declaration for password and pass. Also, what is the point of the declaration char *fp, if you're not going to use it.
What...