Yep, I'm having trouble making that into an equation though.
I also meant less than or equal to an integer n.
So basically its 2^(position of leftmost 1 in binary) but I don't know how to make...
Type: Posts; User: Blasz
Yep, I'm having trouble making that into an equation though.
I also meant less than or equal to an integer n.
So basically its 2^(position of leftmost 1 in binary) but I don't know how to make...
What is an equation to find the largest power of 2 less than or equal to integer n using basic operators, ie, +-*/^ logic gates mod rem?
Nvm, I solved the problem. Had nothing to do with memory. Just a random coding bug.
Nvm, solved.
Thanks. I was getting sscanf and printf mixed up.
I want to use padding when i print stuff.
The normal way is
printf("%5s",string)
But I want the number 5 to be replaced by a variable, as i want the padding to vary based on that...
OK I see now, thanks for explaining.
I'm probably going to leave the code as it is though, because i have limited time, lots more to do and don't want to stuff up anything.
OK I will try to explain why I think the 3 pointers are justified.
My threads have to communicate with each other and share common variables. Without using global variables or pipes between...
Your first post didn't have the right brackets though.
And my added level of indirection is not pointless as I have said....
Anyway, thanks for your help. I appreciate the time you have given...
If you change
// sscanf(buffer, "%s", *ptptp[i]);
to
// sscanf(buffer, "%s", (*ptptp)[i]);
I will be using mutexes but the lack of them at the moment is not causing the segfault. What do you mean the *** is not compatible with sscanf?
The ***, as i said earlier, is a pointer to an array...
Multiple threads will be updating the array of strings and therefore when the struct is passed to them in the form of pthread_create, they can freely edit/share variables through the use of pointers...
This is actually run on solaris so I can't use that I'm afraid.
EDIT: Triple pointer is a pointer to an array of strings.
Whenever I try to access the 3rd element or higher of this 2d array, i keep getting segfaults because apparently i havnt allocated any memory there... but I have.
typedef struct {
char...
Can you suggest a good site that tells you how to setup a sighandler?
The man page didn't really help.
Sorry, I forgot to use the search function here. Was just googling.
Some questions about your code for storing from that thread.
char **args = NULL;
int argcount = 0;
while input
pop...
I am trying to use the execvp command and require an array of pointers for the 2nd argument.
I am storing the arguments in an array of strings. How would I turn that array of strings into an array...
I have come across the term blocking read, but I don't know what it means. I've tried googling but can't find an answer.
I'm guessing it means read from a stream in blocks rather than in lines or...
I don't think I would want to use wait(), as if I sent correct information to the child program, I don't want the parent to stall at wait(), if the child program will not exit, until further input is...
If i was to create a child process that executes a program, and then send some garbage to the child program through a pipe, resulting in an error, how would i detect an error like this in the parent...
If str does not contain the whole line as a string, how will &str[pos] contain the rest of the string, as str only holds the first word as a string?
This prints out a blank line when i enter "test...
Would str contain the whole line as a string (ie including the whitespaces), is that what the %n does?
If not, wouldn't
remainderString = &getLine[pos];
be what i want?
Thanks for that.
Another question, when i use the fgets() function to read a line from a file or stdin, is there a way i can put everything after the first string into a string of its own.
For...
I was wondering if there is a function or an easy way of checking to see if a smaller string is inside a bigger string.
For example,
char *string1 = "hello";
char *string2 = "asdjasd hello...
nvm that, it works now, thanks for your help.