15,548 Topics

Member Avatar for
Member Avatar for hwoarang69

hi i have a 3 part question. can any one explain how can i read from a file and store it in array.(have to use fread). the way i was thinking of doing this was. int ar[50]; int ar2[50]; //read 20 charater at a time while(fread(ar, 1, 20, file) != …

Member Avatar for Ancient Dragon
0
130
Member Avatar for akaicewolf

So I need to write a chaining hash map. I found some examples on the internet and have a pretty clear idea on how to go about it. However the biggest problem I am having is understanding the different hash function. I have a large list of id and they …

Member Avatar for gusano79
0
179
Member Avatar for ilovephil
Member Avatar for vired

Hi! My homework is to make a c program for game of life. I have made my code already, the problem is when i'm running the code the compiler doesn't display any error, but my code still doesn't work well. I have to print in the screen an initial generation …

Member Avatar for vired
0
230
Member Avatar for ilovephil

guys im using reverse polish notation in link list my problem is every time i enter the OPERATOR (+) it will add and that operator display as '0' im having trouble in that operator i need to display it as blank >_< help me guys #include<stdio.h> #include<stdlib.h> #include<string.h> #include<ctype.h> #define …

Member Avatar for ilovephil
0
180
Member Avatar for ilovephil

how can i make the condition if(isalpha(str)) always said that it is invalid conversion from char to int whenever i use if(isalpha(i)) does not print the "That is alpha" help me pls? #include <stdio.h> #include <stdlib.h> #include<ctype.h> #include<string.h> int main () { int i; char str[256]; printf ("Enter a number: …

Member Avatar for Adak
0
188
Member Avatar for ilovephil

how to compare str and the + sign LINE 15 please help me #include <stdio.h> #include <stdlib.h> #include<ctype.h> #include<string.h> int main () { int i; char str[256]; printf ("Enter a number: "); gets ( str ); i = atoi ( str ); if(isalpha(str[256])) { */if(strcmp(str,'+')==0) { printf("That is a plus …

Member Avatar for Adak
0
119
Member Avatar for ilovephil

Hi this is RPN i would like to ask why the free(after) does not remove the after..im still confuse but whenever i print the value of after it is the last node but when im trying to remove it doesn't. #include<stdio.h> #include<stdlib.h> #include<string.h> #include<ctype.h> #define p printf #define s scanf …

Member Avatar for savoie
0
127
Member Avatar for rraj.be

when i try to compile this code i get ERORR: unable to open include file sdl.h [CODE]#include "stdlib.h" #include "SDL/SDL.h" // *** IF USING XCODE ON MACOS X, YOU MAY NEED TO CHANGE THE FOLLOWING LINE TO: #include "SDL_mixer/SDL_mixer.h" #include "SDL/SDL_mixer.h" //Function prototyping action! void musicFinished(); int musicPlaying = 0; …

Member Avatar for maski4real
0
511
Member Avatar for ilovephil

Why i always get the address of the number?? 2295367 >_< #include<stdio.h> #include<stdlib.h> #define p printf #define s scanf #include<ctype.h> struct node { int data; struct node *link; };typedef struct node *nodepointer; void push(nodepointer &top,int number) { nodepointer newnode,temp; newnode=(nodepointer)malloc(sizeof(struct node)); newnode->data=number; newnode->link=NULL; if(top==NULL) { top=newnode; } else { temp=top; …

Member Avatar for histrungalot
0
172
Member Avatar for tubby123

Hi, I get the error "warning: array ‘str’ assumed to have one element [enabled by default]" when I am trying to fill in values inside the string array. [CODE]#include<stdio.h> #include<string.h> #include<malloc.h> char* str[]; int i = 0; int main(void) { for(i=0;i<5;i++) str[i] = (char*)malloc(200 * sizeof(char)); strcpy(str[0],"hello"); strcpy(str[1],"my"); strcpy(str[2],"name"); strcpy(str[3],"is"); …

Member Avatar for Adak
0
1K
Member Avatar for thorpntell

I need to find the period of wave using zero crossings given a set of values that represents a sine wave... I'm a little new to C so there is a chance I made this over complicated, but... oh also, the time of the zero-crossing can be estimated as tz=(t1+t2)/2 …

Member Avatar for rubberman
0
140
Member Avatar for whitech

I have to write a code.The program compute random sentences by using singly linked list date structure.The same word cannot be used more than once. I've already written the some codes which takes the list. [CODE]// random_sentence_operator.cpp : Defines the entry point for the console application. // #include <stdio.h> #include …

Member Avatar for harinath_2007
0
113
Member Avatar for ilovephil

how can i use reverse polish notation in link list using stack i need to reverse the numbers>_< #include<stdio.h> #include<stdlib.h> #define p printf #define s scanf struct node { int data; struct node *link; };typedef struct node *nodepointer; void push(nodepointer &top,int num) { nodepointer newnode; newnode=(nodepointer)malloc(sizeof(struct node)); newnode->data=num; newnode->link=top; top=newnode; …

Member Avatar for BobS0327
0
252
Member Avatar for Oriden

I have been doing a lot of reading and digging and not able to put together a away to do this. Here is my problem. I am building a quiz program in C. I want it to pick at random from a list of questions and compare your answer to …

Member Avatar for zeroliken
0
150
Member Avatar for ilovephil

Any idea how to make restrictions in link list. im still confuse what will i need to make restrictions?? i know the isdigit isalpha etc. for example i can only enter DIGIT,

Member Avatar for ilovephil
0
275
Member Avatar for coreyhughes

I have a question for a homework assignment. This is C, not C++ (sorry! i didn't know where else to go). I have 2 character arrays, declared as char s1[100] and s2[100] in my main function. The part of this assignment I am having trouble with is the readString function. …

Member Avatar for coreyhughes
0
124
Member Avatar for ilovephil

im still confuse in RPN will i use insert at bottom of stack or front and then reverse it? cause my project say's that insert at the bottom of the stack..somebody help me pls

Member Avatar for BobS0327
0
103
Member Avatar for ilovephil

i need that every user input is character it will ask again to enter number until the user's input is correct.my program does not seems to apply the proper condition any help guys? #include<stdio.h> #include<stdlib.h> #define p printf #define s scanf #include<ctype.h> struct node { int data; struct node *link; …

Member Avatar for zeroliken
0
124
Member Avatar for Detkimble

When i try running this code i get an error 'Floating Point Exception'. I dont know why this is happening. [CODE]#include <stdio.h> #include <stdlib.h> #include <time.h> #include <pthread.h> long long int number_of_tosses, number_of_threads, number_in_circle = 0; pthread_mutex_t mutex; void *mc(void* rank) { double x, y, distance_squared, pi_estimate; int toss; long …

Member Avatar for Detkimble
0
160
Member Avatar for angelineang

what is the problem actually in my code?when debug ,it will crash or come out same data. [CODE]#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { int col; int rand_question[3]; int confirm_question[3]; int i; int score=0; char choice; int max_question, total_question; max_question = 3; total_question = 3; srand(time(NULL)); /for(col=0 ; …

Member Avatar for WaltP
0
145
Member Avatar for tubby123

Hi, I don't understand why we typecast malloc. For example, while creating a string/character array, we normally do, [CODE]line = (char*)malloc(200 * sizeof(char));[/CODE] assume we have already declared char* line; I was just reading the malloc man pages and it says that malloc allocates that much memory and returns a …

Member Avatar for tubby123
0
161
Member Avatar for balajirs

Below is a part of an experiement. I am trying to mprotect the whole of the stack area but mprotect needs page aligned space. I can get the address of the current pointer using ucontext.uc_mcontext.gregs[REG_ESP] . But how do I get the page-size aligned address to use in the mprotect …

Member Avatar for gerard4143
0
650
Member Avatar for swissknife007

Question statement Now we represent a natural number N by the maximum numbers that are less than or equal to N in Fibonacci sequence: N = b1*A1 + b2*A2 + … Hence N can be represented as: bnbn-1…b1. For eg, 1 = 1f, 2 = 10f, etc. On writing all …

Member Avatar for Adak
0
101
Member Avatar for chirag_mittal

Hello, I was given a question a few few days back to write a program that lets a user enter a value for an angle and quadrant in which the angle lies is printed using switch statement. I was able to make this program using if-else very easily but making …

Member Avatar for chirag_mittal
0
465
Member Avatar for hwoarang69

i am reading from file called inputfile and storeing in char array line. Lets say the word in char array line is "black cat". than I am strtok word "black" and puting in ch. After that iam testing if the 1st word is black or not. Inside the if statment …

Member Avatar for hwoarang69
0
71
Member Avatar for faithful4ever

My struct is as such: [CODE] typedef struct pqueue { char str[20]; int priority; }pqueue; pqueue q[MAXQ]; [/CODE] When I'm displaying the items in the priority queue, I am trying to sort it by priority, so I have the following comparison function: [CODE] int compareByPriority(const void *a, const void *b) …

Member Avatar for faithful4ever
0
123
Member Avatar for ilovephil

How to add the numbers between nodes example. input 1*2+3 first 2 and 3 will add and it will become 1 5 nodes then 1 * 5 = 5 then node will becaome 5 only this is my sample program #include<stdio.h> #include<stdlib.h> #define p printf #define s scanf struct node …

Member Avatar for begame
0
157
Member Avatar for begame

Hey there! So I have am writing a multi-chat client for my college course. I have completed most of it, however there is a problem which I am unable to identify. When I conect multiple clients to the server only the the last client to connect is able to send …

Member Avatar for begame
0
185
Member Avatar for ilovephil

How to add number in link list using stack POP AND PUSH example i have 1+ 2+3 input the last two operands will first do the addition example and it becomes 1 5 and i put + and will become 6 how? any idea?

0
53

The End.