The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Bad File descriptor error on strcat
Discuss Bad File descriptor error on strcat in the C Programming forum on Dev Shed. Bad File descriptor error on strcat C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

August 18th, 2004, 06:47 AM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 22
Time spent in forums: 3 h 12 m 38 sec
Reputation Power: 0
|
|
|
Bad File descriptor error on strcat
I need help trying to figure why this piece of code gives me a "Bad File descriptor error" everytime I try to run it and invoke fflush. This piece of code simple outputs a char string to the output stream.
What ends up happening instead is that when outputting the first character string to the channel CG_cdukeypad_CHA.Scrpad, its gives the bad file descriptor error, causing the char string not to output. When a second char string is received by the pointer and copied to the channel, the first character string appears on the output stream without the error message. When the third char string is received, the second char string appears on the output stream w/o the error msg, so on and so forth.
Quote: CG_cdukeypad_CHA.Scrpad is a channel to the output stream.
cdukeypad->Scrpad points to the value that I want to pass to the output stream. |
PHP Code:
if (strlen(cdukeypad->Scrpad) > 0){
printf("Character received is %s.\n", cdukeypad->Scrpad);
if (strlen(CG_cdukeypad_CHA.Scrpad) < 25){
strcat(CG_cdukeypad_CHA.Scrpad, cdukeypad->Scrpad);
}
if (fflush(NULL) == EOF){
VP_INFO(("Error writing text to Scratchpad.\n"));
VP_INFO(("Error is %s\n", strerror(errno)));
}
}
Thanks in advance for any help...
|

August 18th, 2004, 07:38 AM
|
 |
Lord of Dorkness
|
|
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
|
|
|
fflush takes a FILE* as an argument, not a file descriptor. NULL isn't a valid FILE*, thus has no reference to a valid file descriptor.
__________________
Functionality rules and clarity matters; if you can work a little elegance in there, you're stylin'.
If you can't spell "u", "ur", and "ne1", why would I hire you? 300 baud modem? Forget I mentioned it.
DaWei on Pointers Politically Incorrect.
|

August 18th, 2004, 07:43 AM
|
 |
I'm Baaaaaaack!
|
|
Join Date: Jul 2003
Location: Maryland
|
|
|

August 18th, 2004, 08:40 AM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 22
Time spent in forums: 3 h 12 m 38 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by DaWei_M fflush takes a FILE* as an argument, not a file descriptor. NULL isn't a valid FILE*, thus has no reference to a valid file descriptor. |
fflush(NULL) is supposed to flush all output streams. And it only gives a bad file descriptor on first run, on subsequent loop thrus, no error occurred.
|

August 18th, 2004, 08:46 AM
|
 |
Lord of Dorkness
|
|
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
|
|
That'll teach me to use age-old documentation  . My apologies.
|

August 18th, 2004, 09:02 AM
|
 |
I'm Baaaaaaack!
|
|
Join Date: Jul 2003
Location: Maryland
|
|
|
Is that age-old or old-age?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|