I want it to just print out a file, the other things is excess I guess I should have taken out. But the key thing is that it works without nanosleep. I want it to sleep for a random time and pick up...
Type: Posts; User: bungkai
I want it to just print out a file, the other things is excess I guess I should have taken out. But the key thing is that it works without nanosleep. I want it to sleep for a random time and pick up...
As the title says, it messes things up. My program is supposed to read in char by char, which works fine without nanosleep, when I add it in, messes things up. Yes I MUST use nanosleep which is why...
I actually tried that, well, I got weird results. I'm making a problem that keeps count of the word with the highest frequency. Say, the finding part is within
void *find_t(void *arg)
Assume...
So, concurrent if I have multiple cpus and no if I don't for the case of a second for loop. What if I have the thread joining at the first loop after I created them?
Ok, that worked. though I'm a little confused as to how pthread_join works.
I have another question. Does my program above run sequentially or concurrently?
So I'm having trouble with threads. What I'm trying to do is create an argc amount of threads that runs some sort of task. In this case, at least open a file..
When I use printf before the...
Say, I have a parent process and a few child processes, and a structure as so:
typedef struct {
char a[101];
int b;
} CS;
And I want to pass this through a pipe.
Thank you, and the processes to argcs is for a bigger purpose, this was just a test. :)
Is this how you do it?
int main(int argc, char *argv[])
{
int i = 0;
for(i=0;i<argc;i++)
{
if(fork() == 0)
{
But if I wanted to compare a non structure string to a structure one? strcpy(tempword,words[0]->word)? How would my tempword be declared?
char tempWord[101]; Would this suffice?
Sorry, I forgot to include that strcmp gives me problems too
So, I've been struggling for a while now figuring out how to properly compare strings. I have
typedef struct {
char word[101];
int freq;
} WordArray;
static WordArray...
I'm just trying to get a simple sorting by swapping algorithm to work on an existing unsorted array..
int a, b;
for (a =...
AndrewHunter, it worked, thank you for your help.
quzah, I will keep in mind about all the advice that have been given and will start cleaning up my code. I understand the reasoning and all.
Well, it works for the first, third, fifth and so on times. However, the second, fourth, and 6th go a little loopy and I don't really know what's going on :S. Sometimes I'm getting the same problem...
AndrewHunter, I added this:
while((scanf("%s", &temp)) != EOF)
{
if (temp != '\n')
{
c = temp;
}
What I'm trying to say is that with fgets(), my output becomes:
name: age:
instead of:
name:
age:
It also completely ignores taking a line of text and skips to the next scanf.
No, this is what I used to have in my program.
printf("name: ");
scanf("%s", &patients[count]->name);
printf("age: ");
scanf("%d",...
Well, as I said above, I've already tried fgets() but it does not prompt for an input. I've also tried delimiters and other functions to get what I wanted to read either just one or two strings but...
While programming I bumped into a block that required me to scan in a name that can take a first name OR a full name. Before this I was using a scanf to read a string, and obviously it does not work...
Record *temp[30];
int k;
count = 0;
for (k=0;k<count;k++)
{
patients[k]->name = temp[k]->name;
patients[k]->age = temp[k]->age;
...
Thanks, it worked! How would I go about clearing the variables then? Since I was more or less doing the same thing.
I have a little problem.
In the following problem I am trying to display an array of pointers in a separate function. The commented section displays the "name" variable correctly, however, the...
Same result with the == 1
I'd need to try it without strtol.
ssharish, but if I were to enter less than 20 inputs, wouldn't it loop until I have 20 inputs?