15,552 Topics

Member Avatar for
Member Avatar for smith32

I don't get it why my threads can't perform properly for writer/reader problem. I think something with the semaphore. but can't solve and online can't help me too. [CODE] semaphore mutex, read, write; void *reader(void *argv) { char buffer[200]; int readNo, i=0; do { sem_wait(&read); sem_wait(&mutex); sem_getvalue(&read, &readNo); fgets(buffer, sizeof(buffer), …

0
96
Member Avatar for ooops.789

hello i am trying to broadcast some values, but i dont see the function of broadcast happening....the code i had written to broadcast is #include <stdio.h> #include <stdlib.h> #include <mpi.h> int main(int argc, char *argv[]) { int rank, size, i, n, num, send; n=atoi(argv[1]); MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD,&size); MPI_Comm_rank(MPI_COMM_WORLD,&rank); if(rank==0) { …

Member Avatar for Mouche
0
129
Member Avatar for maybnxtseasn

Working on an assignment for class. I was able to get the sorts created buy for some reason im having a problem with reducing redundant code within my int main() function [code] /* 1.) create 10, 100, 1000, and 10000 randomly generated elements 2.) Perform The Following Sorts on the …

Member Avatar for Adak
0
178
Member Avatar for allynm

Hello all, I recently installed MinGW on my XP Pro box (SP 3). When I click on the shell icon, the resulting behavior of the MinGW shell console window is incorrect. Initially, the console opens up as it should, complete with frame and scroll bars, but after about 5 seconds, …

Member Avatar for Stazloz
0
146
Member Avatar for FloridaJoe55

Ok, to the point as suggested. Second semester CS assignment to write program that reads maze info in from txt file to create maze a solves the maze recusively. I've got a dynamically allocated 2D array wtih each cell containing number that detemines the walls by bit values and it …

Member Avatar for FloridaJoe55
0
173
Member Avatar for ooops.789

well i am trying to do a program, where the process 0 should start the initialization of sending messages to a random process other than itself, then the random process selected should receive the message and send to another random process. This should happen until the requested number of messages …

0
78
Member Avatar for thendrluca

This is my first post on daniweb :) and i am a beginner in C programming and i don't know so good english :) sorry! This is my program My problem consist of I run the program and i can't get to the [B]scanf("%c",&q);[/B] [I]/* Row 21 after printf. */[/I], …

Member Avatar for thendrluca
0
336
Member Avatar for red711

Hello, I need help to combine a c-program using curl(to retrieve txt files from internet) and another c-program using popen. currently the popen is using the command ls -l (to list the current folder in terminal). I have 2 files, the first one is curl program, which have to retrieve …

Member Avatar for L7Sqr
0
845
Member Avatar for vinodhsml

[CODE]#include<stdio.h> #include<conio.h> //header file declaring void main() { int a,i; clrscr(); printf("\n Enter the Number:"); //get value scanf("%d",&a); if(a%2==0) { printf("\n Not prime number"); } else { for(i=3; i<a; i=i+2) { if(a%i==0) { printf("\n Not a prime"); break; } } printf("\n Prime number"); } getch(); } [/CODE]

Member Avatar for reojavier
-1
132
Member Avatar for techyworld

I've already write a program which allow you to enter name, address and write in the file name,length of name, address ,length of address. File is called "input.dat" Now i need to write another program that reads the file "input.dat" (the one above), displays the name, the size of the …

Member Avatar for thines01
0
110
Member Avatar for ram619

can anyone please tell me whats actually happening in this code. Seems to be as if incremented pointer is pointing to the next bit of same int. Answer is 2,0 Thanks in advance [code=c] #include<stdio.h> #include<conio.h> void main() { int arr[3]={2,3,4}; char *p; p=arr; p(char*)((int *)(p)); printf("%d",*p); p=(int*)(p+1); printf("%d",*p); getch(); …

Member Avatar for Narue
0
353
Member Avatar for natnit

My research group is trying to implement a hash table to reduce the effects of a very costly step in our calculations. Basically, it can take more than an hour to go from A to B, and B is something ridiculously simple, like a number between 1 and 100. A …

Member Avatar for Adak
-1
3K
Member Avatar for linhj

Hi All, I wanna to search a pattern in a txt file called A which is a 2D matrix from another file called B. The requirment is that I need to output the number of matched pattern in file B. But I encounted difficulty of counting the number. Basically I …

Member Avatar for Adak
0
2K
Member Avatar for mameemonster

hello. i make a program for bus ticket reservation and i want to put a seat number in there. so if want to loop the program, and if i pick the same seat number, the program will tell me the seat is taken. is it possible to save information before …

Member Avatar for WaltP
0
106
Member Avatar for whitech

i have to find proper divisors of a positive integer.for instance,the proper divisor of 15 are 1,3,5. input 15 output 1 3 5 like that. Thank you for your helps.

Member Avatar for cse.avinash
0
200
Member Avatar for mameemonster

hi. this is my program for bus ticket detail. at the bottom of my program, i want user to input yes or no for loop this program. but before i can input anything, it already told me that 'Please input the correct answer'. it is like i already input something. …

Member Avatar for D33wakar
0
140
Member Avatar for varsha0702

Can any body tell me the difference between file descriptor and filepointer in C on linux? and when to use what?

Member Avatar for karthikvb17
0
447
Member Avatar for swissknife007

[CODE]#include<stdio.h> #include<conio.h> struct bnode{ struct bnode *child[5]; int count; int value[5]; }; typedef struct bnode node; node * root=NULL; void insert(int val); int put(int,node*,int *,node**); void fillnode(int ,node *,node*,int); int search(int,node *,int *); void insert(int val) { int i,flag; node * c,*n; flag=put(val,root,&i,&c); if(flag) { n=(node*)malloc(sizeof(node)); n->count=1;//setting count 1 n->value[1]=i;//setting …

Member Avatar for gourav1
0
574
Member Avatar for MrNo

Ok so, I'm working on a program that is suppose to solve a function: (1+ (x^2) / sqrt(3x+6)) / (x^2 - 5x) As you tell by the function the denominator cannot be = to 0. So here's my code that I'm having trouble with. [CODE] #include <stdio.h> #include <math.h> int …

Member Avatar for MrNo
0
126
Member Avatar for mameemonster

hello. i have a problem in selecting destination and time. when i select any number in destination the program always tell me that i choose number 1 (taiping). and the time it always show 1030 even i input number that is not 1. please tell me where i'm wrong here. …

Member Avatar for mameemonster
0
112
Member Avatar for Liuhh00

hey guys lol i spent 5 hrs thinking about building this asterick pattern and i am still getting troubled by the spacing for the 3rd pattern , anyone can help me to reduce 1 spacing so the 3rd pattern isn't out of place?XD [CODE]#include <stdio.h> int main() { int c,c_2,c_3,c_4,c_5,c_6,c_7,c_8; …

Member Avatar for Liuhh00
0
133
Member Avatar for mkab

Hello everyone. I'm trying to code the cd shell command in c. I used chdir function to code it but the problem is that when I execute the program on the terminal it doesn't change the directory. I kept a series printfs and conditions to test if it changes, though …

Member Avatar for mkab
0
6K
Member Avatar for sahilk50

hi guys, iam a beginner in c and i have got a project to make a program to keep the track of stock and cash of a shop i had done my work but i want to add purchase and iam unable to keep the work in history as a …

Member Avatar for WaltP
0
331
Member Avatar for joshThtch

Building a phonebook program for school--very much a work in progress. I still need to write a sort function, tweak my delete function, etc. But actually what I'm hoping you folks could answer is hopefully simpler--for some reason I seem to have a while loop that is executing twice, and …

Member Avatar for joshThtch
0
214
Member Avatar for dan1992

This program must calculate permutations but it gives me a result with smiley , Can someone help me, Thanks!! [CODE]#include <conio.h> #include <stdio.h> #include <math.h> const n = 10,num=4; int i,a[n]; void tipareste(){ int i; for(i=0;i<num;i++) { printf(" %d \n", a[i]); } } void permuta(int k) { int i,x; if(k==1) …

Member Avatar for dan1992
0
132
Member Avatar for coding101

When you include a header file like sys/stat.h you can use the functions like stat. But where is the function body? I didnt write the body, yet it still does something.

Member Avatar for Narue
0
83
Member Avatar for corby
Member Avatar for Narue
0
143
Member Avatar for cse.avinash

Hello everyone I am trying to apply [URL="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes"]Sieve of Eratosthenes[/URL] in program, but its not working. Here is my code:-- [CODE] #include<stdio.h> long long arr[10000]={0}; int main() { long long i,j,num,inc=2,m=0; num=5000; for(i=0;i<num;i++)arr[i]=i; for(i=2;i<=num/2;i++){ if(arr[i]>0) { for(j=inc*i;arr[j]<=num;j=j+i) arr[j]=-1; inc++; } } for(i=0;i<num;i++)printf("%lld ",arr[i]); printf("\n"); return 0; } [/CODE] This code …

Member Avatar for cse.avinash
0
100
Member Avatar for neveragn

how do you promt the program from positive integars terminatd by -1 .. and then ask for smallest of these integars. I did everything except when I add (!= EOF) .. It shows the same prompt multiple times should I still keep the code or is there a specific error? …

Member Avatar for neveragn
0
255
Member Avatar for neveragn

HI, I'm writing a code for the very first time, and I'm completely stuck. Some guidance would be great. I'm writing a C program that reads integars from file "integars.dat". The program should show how many numbers you have entered, how many among them were even, and how many were …

Member Avatar for neveragn
0
137

The End.