18,490 Topics

Member Avatar for
Member Avatar for CKShia

Hi I am new in C programming language... I am writing a simple FTP Server-Client program, and I want to print out the client IP address for each successful login. Here's the code that I encountered warning: `struct sockaddr_in ser_addr;` `printf("IP: (%s); Port: (%d)\n",` `inet_ntoa(ser_addr.sin_addr), ntohs(ser_addr.sin_port));` When I compile the …

Member Avatar for PieterBeyens
0
204
Member Avatar for Sean Raina

Can some one help me write a c program for my "Internal Assessment" at school? Its a program that should be over 5oo lines but I need your help urgently. The dead line is two days from now. If your interested, email me at "[email protected]", where I will give you …

Member Avatar for bumsfeld
0
75
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
153
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
197
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
241
Member Avatar for joseph_butler

I have written the following code to try to get my GPA calculator program to work. I am not allowed to use arrays. I only know what I am doing from the videos I have watched on youtube and the slideshows that we get from our instructor. Unfortunately, the slideshow …

Member Avatar for absar.mazhar
0
4K
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
199
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
200
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
133
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
152
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
530
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
193
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
173
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
137
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
274
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
164
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
302
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
142
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
128
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
146
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
182
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
161
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
187
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
842
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
123
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
498
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
84
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
157
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 Member #653581
0
170
Member Avatar for Member #653581

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 Member #653581
0
201
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
61
Member Avatar for ilovephil

How can i store strings in my program. #include<stdio.h> #include<stdlib.h> #include<string.h> #define p printf #define s scanf struct node { char nbook; struct node *next; }; typedef struct node *nodepointer; void addbook(nodepointer &head,char book) { nodepointer newnode; newnode=(nodepointer)malloc(sizeof(struct node)); newnode->nbook=book; newnode->next=head; head=newnode; } void display(nodepointer head) { if(head==NULL) { p("\nNothing …

Member Avatar for Ancient Dragon
0
222
Member Avatar for luislupe

I programmed some functions that use a dynamic array of [CODE=c] double ** array [/CODE]. But know, I want to test the results with a small array of 5 x 5 elements and use this array in the functions I coded. My problem is that I can find no way …

Member Avatar for luislupe
0
266
Member Avatar for TreeBranches

My program begins by opening a dictionary file, the first line of which contains the number of words in the dictionary. If I print the words immediately after scanning them into the arrays, they appear fine, but if I later examine a previous entry, I can see it has been …

Member Avatar for TreeBranches
0
238
Member Avatar for vedro-compota

Hello everyone)) Guys please tell me - is there any way to create thread in lunux , which will not executed itself (at all) - until will get SIGCONT signal? I can't thread self stopping after creation , because in this case - we cann't be sure that the thread …

Member Avatar for vedro-compota
0
417
Member Avatar for faithful4ever

I'm trying to get a user's input repeatedly until he/she types in 'done'. So what I have done is: [CODE] printf("Enter a name to save and its priority\n"); scanf("%s %d", q[rear].str, &q[rear].priority); [/CODE] How can I check for the user's input until he types the word 'done'? So if the …

Member Avatar for faithful4ever
0
151
Member Avatar for ilovephil

As you can see this is my program.my problem is how to store strings in my program I can store only single character.. any one can help me? =( #include<stdio.h> #include<stdlib.h> #include<string.h> #define p printf #define s scanf struct node { char nbook; struct node *next; }; typedef struct node …

Member Avatar for Banfa
0
145
Member Avatar for IcyFire

Im trying to write a program that will scan both characters and numbers from a user then put the number into an array or call another function based on the user input. For example the user will type 'Insert 3' and this will call the function to put 3 into …

Member Avatar for IcyFire
0
194
Member Avatar for ilovephil
Member Avatar for VernonDozier
0
65
Member Avatar for ilovephil

can i return a value using CHAR DATA TYPE? NOT INT? ex.int data; int value(ex.data) return data; how about this ex.char name; int(ex.name) return name; possible or not?

Member Avatar for ilovephil
0
100
Member Avatar for cono1616

Hi I am fairly new to C and was wondering if anyone can help me out. I am trying to take a 2D array and scan for individual letters. I have a hangman game and the program takes a word from words.txt and assings it to the char word[20][30] For …

Member Avatar for thines01
0
28
Member Avatar for shean1488

Hi everybody, I just start lerning C I'v heard a lot about pointers but not really sure were to put them. (or may be I'm wrong may be I just made some mistake) pls take a quic look. [CODE]/* This program will delete all simbols * from s1 that s2 …

Member Avatar for zeroliken
0
139
Member Avatar for str91

Hi hwo to write total of 10 first setences (C languege) -1,+2/3,-3/5,+4/7,-5/9,...

Member Avatar for zeroliken
0
157
Member Avatar for eranre

I was wondering if anyone can assist me with a problem that I have with C Bluetooth programming (Linux Bluez). I am using Ubuntu 10.04, BlueZ 4.60. My goal is to have a L2CAP socket in which there will be minimal delay for sending data between 2 computers. So far …

0
195
Member Avatar for M09

Hello I have an experience in programming previously, and now i want learn C . how can i learn it, i means where i can learn it . in fact i am looking about sources to learn like books,web sites, and vedios. and i hope you Heuristic to the good …

Member Avatar for M09
0
302
Member Avatar for zifr

how can i write a program, which accepts the starting address (in BX) of a text (terminated by a “%”) stored in data segment and replace all lower-case letters by their upper-case counterparts. Non-alphetic characters will remain as is.(8086)

Member Avatar for spixy
0
6K
Member Avatar for henriquec

i am starter in c/c++ i need to convert this: [CODE]cout <<" "<<ch1<<ch2 <<" "<<ch1<<ch3 <<" " <<ch0<<" "<<ch1 <<" "<<ch1 <<ch4 <<" "<<ch1<<" "<<ch3<<ch5<<" "<<ch0 <<" " <<ch2<<ch3<<" "<<ch1<<ch5<<ch0<<" "<<ch1<<ch4 <<"\n";[/CODE] in printf, but i dont know how to do it.

Member Avatar for thines01
0
247
Member Avatar for Member #948970

Hi, I am programming some console application that updates itself periodically from Internet. (windows.h + pthreads for win32) I want to do something like: [CODE] MAIN FUNCTION: create thread launch updater THREAD: infinite loop - starts the main application, exits if application ended normally but when it was killed by …

Member Avatar for Ancient Dragon
0
1K

The End.