15,551 Topics

Member Avatar for
Member Avatar for socket_to_me

Hello. This is my first post, and I am fairly new to C. I am writing a socket program and I am getting a segmentation fault upon runtime. My program compiles fine. I'm pretty sure it is due to my implementation of my data structure. My struct looks something like …

Member Avatar for abhimanipal
0
94
Member Avatar for darkdai

does anyone know whats wrong with my function? [CODE] void quarter(detailstype info[]) { int i,j; for(i=1; i<4; i++) { printf("for month: %d", info[i].month); for(j=1; j<emp; j++) { info[i].qt1=info[j].sal_amount+info[i].qt1; } printf("%f", info[i].qt1); } }[/CODE] it is giving me this error: error C2111: pointer addition requires integral operand

Member Avatar for abhimanipal
0
95
Member Avatar for dnk77

Gday all, I am studying/part time teaching C++ in an australian technical college. I have been asked to write a problem and solution for a class of young students. This is what i have so far: The header file 'DIGI_O.OBJ' contains functions 'void setup(void), 'int Ain(void)' and 'void Bout(int)'. The …

Member Avatar for Nick Evan
0
70
Member Avatar for yasemin

Hi, I have a question regarding a program I'm writing in C. I have a few variables which I would like to assign a random number to. However the sum of all the numbers I assign should equal 1. I have not been able to find a way to do …

Member Avatar for finito
0
94
Member Avatar for azra36

i have an unhandled exception cx0005:access violation in VC6++ while i try to run my c code with main.exe it gives a window showing to send a error report or to debug, while i give debug, it takes to fwrite file an breaks at the point --> if (anybuf(stream))//this is …

Member Avatar for azra36
0
360
Member Avatar for gargi3542

hie all, i needed to make a code in simple turbo c for ethernet packet injection as well as data reception. I tried the code in windows but its not working. possibly due to linux based commands. plz help me..

Member Avatar for gargi3542
0
190
Member Avatar for brad82

Hey all, I am pretty new to C and am trying to make a basic HTTP server to learn more about sockets. I managed to get the sockets working fine, and sent some data to the browser when I hardcoded the data. However I am now trying to read from …

Member Avatar for Aia
0
108
Member Avatar for appunu

[CODE]#include <stdio.h> int main(void) { int a,b,c; printf("Enter the sides of the triangle"); scanf("%d%d%d",&a,&b,&c); if(a+b<c || b+c<a || c+a<b) printf("cant form a triangle"); else if(a==b==c) printf("eq triangle"); else if(a!=b && b!=c && c!=a) printf("sca triangle"); else if(a==b&&b!=c || a!=b&&b==c) printf("Iso triangle"); } [/CODE] am starting to code.. i have coded …

Member Avatar for NP-complete
0
118
Member Avatar for thomasekugm

Here is my assignment rules, i am stuck and cannot find what it is i am doing wrong. If some one could help me i would appreciate it * The main routine must be a 'manager' routine, which means o The function can declare variables o The function can call …

Member Avatar for Aia
0
152
Member Avatar for emmas4impact

Hello everyone my task is to write a [COLOR="Green"]program that reads quizzes from a file 'q.txt', randomly selects a number of questions, and presents them to the user one-by-one, collecting user answers. After user has answered all questions, program gives user the score. [/COLOR] please can someone give me the …

Member Avatar for abhimanipal
0
116
Member Avatar for gameon

hey i used findfirst and findnext function but they can access only a path which is given by us. i want to access all folders and file of a drive like a antivirus do, when it scans the drive.... do u know how can we do it using c language?

Member Avatar for Aia
0
190
Member Avatar for xenanovich

hi, (on a linux system) i wrote the following code snippet to 1. write to a serial port 2. read the data that i have just written to the serial port. the write is functioning, but the read is not. if i use just the read (without "write", but by …

Member Avatar for xenanovich
0
1K
Member Avatar for lionaneesh

[code]// Dumps raw memory in hex byte and printable split format void dump(const unsigned char *data_buffer, const unsigned int length) { unsigned char byte; unsigned int i, j; for(i=0; i < length; i++) { byte = data_buffer[i]; printf("%02x ", data_buffer[i]); // Display byte in hex. if(((i%16)==15) || (i==length-1)) { for(j=0; …

Member Avatar for WaltP
0
211
Member Avatar for Silen

I'm writing a cross-platform code and I need to be sure the following won't make me trouble. [code=c] struct X { unsigned char a:3; unsigned char b:5; }; [/code] Is using other then int types is part of the ANSI C? Will it be compiled with every compiler?

Member Avatar for Silen
0
133
Member Avatar for Xufyan

i want to write a program that prints the value in array which are at odd position, i've this for single dimensional array but confused about 2-D array. Single dimensional: [CODE] int main(void) { int num[10]; int i; for (i=0;i<10;i++) { printf ("Enter %d value: ",i); scanf ("%d",&num[i]); } for …

Member Avatar for Xufyan
0
169
Member Avatar for lionaneesh

[CODE] #include<stdio.h> #include<string.h> #include<arpa/inet.h> #include<netdb.h> #include<sys/types.h> #include<sys/socket.h> #include<fcntl.h> #include<sys/stat.h> #include<stdlib.h> #include<time.h> int main() { FILE *logs; logs = fopen("/home/aniroot/logs/log.txt","a"); if(logs = NULL) { printf("fopen failed ... There would be no log for this session!!!"); } int sockfd,newfd; int err; struct addrinfo *res,*p,hints; struct sockaddr_storage their_addr; socklen_t addr_size; int yes=1; char …

Member Avatar for abhimanipal
0
135
Member Avatar for Dave Sinkula

Many times [inlinecode]strtok[/inlinecode] is recommended for parsing a string; I don't care for [inlinecode]strtok[/inlinecode]. Why? [list][*]It modifies the incoming string, so it cannot be used with string literals or other constant strings. [*]The identity of the delimiting character is lost. [*]It uses a static buffer while parsing, so it's not …

Member Avatar for Aia
0
1K
Member Avatar for gkaykck

Hi I am trying to make my homework about a command line calculator, and i am trying to divide the entered string into small parts and i am trying to use strtok for this. [CODE] #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> struct var { char name[10]; double value; …

Member Avatar for gkaykck
0
595
Member Avatar for Iam3R

Hi , i know one method of deleting a record from a binary file. that is : read the contents of the file and every time check for some criteria based on which we want to delete the record. if record does not match criteria then write to new file …

Member Avatar for Adak
0
1K
Member Avatar for comput scince

i have a project anc i need to do an interface to my c program , there is any functions to do it?

Member Avatar for comput scince
0
84
Member Avatar for menonnik

I have a code like [code] int a=10; a=(++a)+(a++)+(a++)+(a--)+(--a); printf("%d",a); [/code] this gives the output as 51. while [code] printf("%d",(++a)+(a++)+(a++)+(a--)+(--a)); [/code] gives 56 as ouput. can you please explain the flow in both the statements.

Member Avatar for JuhaW
0
94
Member Avatar for Ferny84

Hi everyone, I am having some trouble here... I am asking the user to enter a file, and that file will read the contents and determine if the student will pass or fail the class. That part I am having trouble with is when I have to decide if the …

Member Avatar for csmgsarma
0
119
Member Avatar for darkdai

hey everyone, im tryin to generate random strings and store them in an array. can anyone please show me?

Member Avatar for Narue
0
119
Member Avatar for MrDiaz

Hey folks, I am trying to normalize a view on a given output. This is how it works, I need to print several characters but the maximum chars i can print have to be 40 per line. [QUOTE]aaaaaaaaaaaaaaaaaaaaaaaaaaaaa...till 40 aaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbb[/QUOTE] The algorithm works as follows: I have to find …

Member Avatar for MrDiaz
0
124
Member Avatar for MrDiaz

I have an array codes[26] which contains numbers inside {25,4646,23,12,.....29} Each position in the array corresponds to a letter of the alphabet. code[0] is a, code[1] is b, etc... I'd like to print the occurrences of each letter, something like this. If there are 12 A's, 5 B's AAAAAAAAAAAAA BBBBB …

Member Avatar for MrDiaz
0
115
Member Avatar for cmsc

I'm trying to run this code in cygwin 1.7 but i get segmentation fault when I choose to search. I tried this in cygwin 1.5 before but it works. does anybody know the reason why it won't work in cygwin 1.7? here's the code [CODE] /**************** Rachel Perono running BST …

Member Avatar for Tellalca
0
115
Member Avatar for MrDiaz

Hey everyone, I have a series of loops that read through a text file and then output the occurrences for each letter on the file. This seems to be fine when using small text only. When providing a lot of text it just takes too many CPU resources and that's …

Member Avatar for Tellalca
0
115
Member Avatar for lionaneesh

[CODE]/* This function accepts a socket FD and a ptr to a destination * buffer. It will receive from the socket until the EOL byte * sequence in seen. The EOL bytes are read from the socket, but * the destination buffer is terminated before these bytes. * Returns the …

Member Avatar for abhimanipal
0
193
Member Avatar for tenix

Hi, Is it possible to read a file only to get the first 100 bytes from the begining and the last 100 bytes at the end? I have to get info from files that are in the first 100 bytes and in the last 100 bytes of the file and …

Member Avatar for tenix
0
8K
Member Avatar for tskellyfla

Hi, I'm a student learning to code in C. This is what I have only when I compile it, gcc, I get two error messages and I don't understnd why. The messages are '67: error: expected declaration or statement at end of input' and '67: error: control reaaches end of …

Member Avatar for Aia
0
264

The End.