Search Results

Search: Posts Made By: cleopard
Forum: Programming 08-21-2008
6,459
Posted By cleopard
binary for 'printf' routines
This is a quick question: is '%b' a valid conversion to use in any of the 'printf' routines for binary data? I did some searching through old posts in this site and found some that said it is,...
Forum: Programming 08-21-2008
3,080
Posted By cleopard
substituting one string for another
I have a Linux C program I'm writing that has one section where, within a large string, I need to substitute a smaller string for another, and those probably won't be the same size.

For instance,...
Forum: Programming 08-20-2008
6,346
Posted By cleopard
const char at_sign = '@'; char str[] =...
const char at_sign = '@';
char str[] = "fred@email.com;
char *ptr;
.
.
.

ptr = strrchr (str, '@');

vs.

ptr = strrchr (str, at_sign);
Forum: Programming 08-20-2008
6,346
Posted By cleopard
char constants vs. hard-coding
This might be a silly question, but I thought I'd ask anyway. If I'm writing in C, isn't it more efficient to, for instance, use constant character variable set to 'A' instead of hard-coding a...
Forum: Programming 08-13-2008
9,333
Posted By cleopard
Yeah, that worked, I guess I should have done...
Yeah, that worked, I guess I should have done that earlier, but since those are constants, it just seems cleaner to assign them in the declaration line. I figured that, with strings, the null was...
Forum: Programming 08-13-2008
9,333
Posted By cleopard
And one more thing: why if you have a declaration...
And one more thing: why if you have a declaration like this:


char str[] = "teststring";

int str_l = sizeof(str);


will it set 'str_l' to 11, not 10? Is it counting the null byte?
Forum: Programming 08-13-2008
9,333
Posted By cleopard
I have the constants now declared as: const...
I have the constants now declared as:

const size_t comment_begin_len = strlen(comment_begin);
const size_t comment_end_len = strlen(comment_end);


and get the same result:

emhttpc.c:65:...
Forum: Programming 08-13-2008
9,333
Posted By cleopard
Taking the 'const' off gave the same results.
Taking the 'const' off gave the same results.
Forum: Programming 08-13-2008
9,333
Posted By cleopard
#include <sys/stat.h> #include <stdio.h> ...
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <resolv.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
...
Forum: Programming 08-13-2008
9,333
Posted By cleopard
'strlen' of a constant string
In a declaration, I have:

const char comment_begin[] = "<!--";
const char comment_end[] = "-->";

const int comment_begin_len = strlen(comment_begin);
const int comment_end_len =...
Forum: Programming 08-12-2008
9,633
Posted By cleopard
Yes, that will work just fine; I guess I should...
Yes, that will work just fine; I guess I should have thought of something like that before.
Forum: Programming 08-12-2008
9,633
Posted By cleopard
enumeration types in C
If I want to declare an array of structures in C and have the number of items in that array to correspond to the items of an enumeration, is there a way to access the maximum value in the enumeration...
Forum: Programming 08-07-2008
5,599
Posted By cleopard
Thanks for the feedback, folks. Yes, I tried the...
Thanks for the feedback, folks. Yes, I tried the 'tr' string and that looks like it will work just fine. One last question. The sample that Franklin gave indicated the characters that are legal. ...
Forum: Programming 08-07-2008
5,599
Posted By cleopard
string with invalid characters
This is a pretty straight-forward question. Within a program of mine, I have a string that's going to be used as a filename, but it might have some invalid characters in it that wouldn't be valid in...
Forum: UNIX and Linux Applications 07-21-2008
2,301
Posted By cleopard
gengetopt problem
I'm new to the 'gengetopt' command to generate command line prompts for (in this case) a C program. I made appropriate changes to the "Makefile*" files, including the 'gengetopt < xxxxx.ggo' line in...
Forum: Programming 07-08-2008
3,840
Posted By cleopard
Thanks for the reply. I think I know why the...
Thanks for the reply. I think I know why the segfault happened, having to do with the logic of my program and the fact that I changed a bit of it to try giving 'getline' a smaller character string;...
Forum: Programming 07-08-2008
3,840
Posted By cleopard
'getline' questions
I have a C program I've written that includes a 'getline' call that is used to read a line at a time from a file and process the information in each line. A potential problem comes up since I don't...
Forum: Programming 05-01-2008
4,241
Posted By cleopard
macro expansion in vi editor
The emacs editor is able to expand macros in C and since I normally use vi editor, I wanted to find out if there's a similar capability for that.

I'm not sure if this is the correct forum for this...
Forum: Programming 03-28-2008
38,353
Posted By cleopard
I found a code snippet while via a web search: ...
I found a code snippet while via a web search:

struct hostent *hp;
.
.
.

hp = gethostbyname (cat_str);
.
.
.

for (i=0 ......
printf( . . . . . inet_ntoa(*(struct in_addr...
Forum: Programming 03-28-2008
38,353
Posted By cleopard
I tried this: struct in_addr host_addr . ...
I tried this:

struct in_addr host_addr
.
.
.
.

host_addr.s_addr = inet_addr(cat_str);
printf("IP address ==> %s\n", inet_ntoa(host_addr));


All I get is a series of 255.255.255.255...
Forum: Programming 03-28-2008
38,353
Posted By cleopard
host name to IP address
There's a piece in a C program I'm writing (Linux) that simply needs to take a host name and return an IP address (e.g., take 'mail.gnu.org' and return 199.232.76.166). I've gotten a successful...
Forum: HP-UX 07-10-2007
5,062
Posted By cleopard
Thanks porter and blowtorch, I'll see what I can...
Thanks porter and blowtorch, I'll see what I can find.
Forum: HP-UX 07-09-2007
5,062
Posted By cleopard
symbolic debugger for UNIX
I'm wanting to use a symbolic debugger to find a problem with a C program I'm working on in the HP-UX engine B.10.20 E 9000/800 environment; I've used the GNU debugger on Linux, but it does not exist...
Showing results 1 to 23 of 23

 
All times are GMT -4. The time now is 09:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy