no, I was sure the file wasn't empty and tried it on a couple files. the command was
programname /etc/passwd file.txt
programname program.c file.txt
Both have read permissions for the user.
Type: Posts; User: crash88
no, I was sure the file wasn't empty and tried it on a couple files. the command was
programname /etc/passwd file.txt
programname program.c file.txt
Both have read permissions for the user.
I'm just learning the unix system calls and have used lseek a few times and never had a problem with it. It's a pretty straight forward system call but this one is getting me. I'm getting the error...
too bad it wasn't stdin. the output was this when I tried writing each character to the screen
crash@venus::~/programs/usp/ch2$ ./frontdesk file.txt
1 getoccupier
2 freeroom
3 addguest
4...
I changed the char to an int and nothing changed. Thanks for the advice.
of course it occured to me. I explained that withought the use of clearstdin I get the output
Enter last name: Enter first name:
The both go on the same line so stdin obviously needs a douche.
I'm trying to complete an excercise to learn unix system calls and one of the functions in the program was giving me only partial output. So I wrote a test program that is almost identical to the one...
thanks.
I prompt for input and the scanf function is skipped over because the stdin buffer contains data. How can I flush this beforehand? Everywhere I look tells me it's system dependent and I'm on linux...
thanks
sorry, I posted this the lazy way. the loop is needed in the program this is for (this is just the part that's not working. In the actual program, each case statement has a function.
what is wrong with the following snippet? are intergers not allowed in switch statements?
#include <stdio.h>
int
main()
{
int i;
on linux, would it be safe to open /dev/null as a regular file for write only to flush stdin? or is there another way to do it?
In the faq, there is a section saying that it is unsafe to fflush(stdin) (it doesn't work correctly anyway). I'm having a problem with a function and an infinate loop with switch statement where the...
Thanks. I still get confused with pointers.
Your code is hard to read. It's pretty conventional to use tabs for things like if statements, loops, etc:
example:
for (i = 0; i < 10; ++i) {
scanf("%s", str);
}
You'd probably have...
This is completely confusing me. I have a call to a function:
case '5': if ((findfree((int)&roomnum)) < 0)
printf("No available rooms\n");
...
I'm having some trouble with this. It seems basic enough but I keep getting a large integer in the range of 1000-2000 instead of what it looks to me like should be 1-10 or return a negative number.
...
I'm passing it as a value intentionally since the value will be changed in the createfile function. All it needed was a typecast. For some odd reason I cannot pass a value of that type without the...
ssize_t is a type in unistd.h. It's used to count the number of chars written or read to or from a file. I'm guessing it's pretty standard since I'm learning this out of a unix system programming...
I keep getting the error:
openfile.c: In function `openfile':
openfile.c:27: warning: passing arg 1 of `createfile' makes integer from pointer without a cast
I don't fully understand the meaning...
Is there such a function or does one have to write it himself using getchar() and appending the chars into a buffer in a loop?
sorry I wasn't clear in my initial post. I'm reading from the command line.
Is there an ansi c function equivelant to the c++ getline function? The only way I can think of to do this is to use the read system call (on linux), but I wouldn't know what to do if I were trying...
If they aren't I know it's possible to make a bool type using define macros. The reason I'm wondering is because I'm thinking about programming with MFC.
Where are functions in ANSI C such as strlen() or getchar() defined on a linux system? You are able to look through the header files but there's no definitions. Sometimes you see a declaration. I...