15,551 Topics
![]() | |
i did a simple bubble sort but it is ot working . help me out. [CODE] #include<stdio.h> main() { int i,j,k; int a[]={7,9,4,2,3,6}; for(i=0;i<7;i++) for(j=i+1;j<7;j++) if(a[j]<a[j-1]) { k=a[j]; a[j]=a[j-1]; a[j-1]=k; } for(i=0;i<7;i++) printf("a[%d]==>%d",i,a[i]); } [/CODE] | |
As this is my first post on this forum I want to say "Hello!" to everybody and I hope that we'll help each other as much as we can and we'll be very good friends. :) So, this is my problem ( a rather simple one but I don't know … | |
hi can u ppl help me on this. can i use multiple enums in a single c program, if so is there any constrain on it? [CODE]enum pattern1 {red, green, yellow} pt1; enum pattern2 {orange, blue, black} p2; enum pattern3 {white, grey, violet} p3;[/CODE] is this possible???? | |
I want my program to just continue as long as the user press any key How do we do it with only use of scanf?? for example: int main(void) { while(1) /*my program goes here*/ printf("Hit any keys to continues......"); scanf // how? } | |
i have to write a program, in which i have to make pointer to point to the character, where it last occured in a string. For example: String: Lord of the rings Character: r Pointer points to the last 'r' in the string, that is in the word 'rings'. If … | |
I want to Write a program that determines the day number (1 to 336) in a year for a date that is provided as input data. As an example, January 1, 1994, is day 1. December 31, 1993, is day 365. December 31, 1996, is day 336, since 1996 is … | |
Greetings all; what I'm trying to do is create an array of structs dynamically by using functions for allocation, display, and then freeing memory. I'm *able* to do the process if it's within scope of the foo declaration, but the initFoo function throws an exception. I *think* it's the order … ![]() | |
hi guys .. i have an assignment .. and i didn`t now that i have to do it by tomorrow and now i have no time .. i will be thankful if you can help me.. "Write a program that determines the day number (1 to 336) in a year … | |
how can i convert this into a struct? the program is prnting all the even nos [CODE]void main() { int num[5],even[5],count,j=0; clrscr(); printf("Enter 5 numbers\n"); for(count=0;count<5;count++) { scanf("%d",&num[count]); } for(count=0;count<5;count++) { if((num[count]%2)==0) { even[j]=num[count]; j++; } } printf("EVEN:\n"); for(count=0;count<j;count++) { printf("%d\t",even[count]); } getch(); }[/CODE] | |
I'm working on a tcp server and client for linux. I want the tcp server to send a 10MB file to it on request and I want the client to save it to local disk. I would appreciate any help on it. Thanks for the help. jdm server: [CODE] /* … | |
[CODE] unsigned int *a; a = (int*)malloc(1*sizeof(int)); a[0] = 10; a[1] = 20; a[100] = 40; printf("%u",a[100]); [/CODE] I have created a pointer named a and allocated 'single' int space for it but still i can store and retrieve more than that. This code runs. Then what is the need … | |
hello everybody, please help me in solving the problem of finding the XOR value of 4 bits as i require it in my project. i tried ^ sign, but it doesnt work for four variables? kindly help | |
Hello everyone, I've been having a problem with some of my scanf() functions being skipped after I input a string with a space in between (e.g Jack Daniels). I've been trying to fix it, but it has been driving me crazy. [CODE]#include <stdio.h> #include <stdlib.h> struct Student { int studentNumber; … | |
i got no idea how to correct the error,can help me? this is a chem quiz that contain 20 question but i need to random everytime 10 question,other than this,also have a calculator,& mini games [CODE]#include<stdio.h> #include<math.h> #include<stdlib.h> #include<time.h> #include<windows.h> int main (void) { int option,question,i,count,z=0; char choice,game,quit; int selection; … | |
Greetings. I'm currently implementing small ANN on my microcontroller. I need to calculate sigmoid activation function. The problem is that I cannot use standard c libraries like math.h so I need custom written pow function. This is how it will be used:pow(e,-(someFloat)); Did anyone have already implemented something similar ? | |
hi when i try to use atof i get different values every time i run my app code: [CODE]#include <stdio.h> #include <string.h> #include <math.h> int main(int argc, char **argv){ char* a = "100"; double b = atof(a); printf("%f", b); }[/CODE] why do i get different results everytime i run my … | |
Dear all, I'm a C beginner and I was doing a small practice nested loop on C when I got a very strange error which when the console opens tells me that my program has stopped working. here is the code: [CODE] #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> … | |
is it possible in C to do an unfix size array like in Java ? if so, howto ? thx guys Dark | |
Hi, I want to filter .BMP image with 3x3 digit matrix. Basicly it is multiplying image pixels by numbers in matrix. Any suggestions how it should be done? I know that i have to open a file using fopen() I did that. Should I just loop through whole image and … | |
im writing a chat server in c and am need help. my server can write to a socket, the client can read from the socket. How do i have the client write to the socket and have the server read from the client socket? server.c [CODE] #include <stdio.h> #include <unistd.h> … | |
Dear All, I have a function with input parameter as const u_char *p. So when I write like this printf("\n\n Char value p : %.2x",(unsigned int)p[1]). It gives me a hex value. How to print the whole p value which method is best to use. I need to analyse it … | |
![]() | Hi guys, I'm trying to develop a card program, which seems to be working fine, with the exception of the dealing part. The deck is initialised, shuffled, then is supposed to deal out 5 cards without duplicates. However I keep seeing duplicates when I deal. I've ran though it countless … |
Hi, I have a task to perform which all to do with the smurfs, reading from a file and doing some simple stuff to it. The last part I need to do is print out a list of all smurfs and their corresponding role in alphabetical order. I am hoping … | |
for example, i want to combine two number 6 and 8 and it will equal 68. is this possible in C? [ICODE]int a = 6, b = 8,c; c=ab; [/ICODE] and c will = 68. | |
Hello; For the below program, I am trying to create a procnanny program which will monitor the processes according to the specification said in a configuration file. The parent process will create fork() child processes each for monitoring a process as specified in the configuration file. The configuration file is … | |
[CODE]void merge() { if(start==NULL) { start=start2; } else { temp=start; while(temp->next!=NULL) { temp=temp->next; } temp->next=start2; } temp=start; if(start==NULL) printf("\nList is empty"); else { printf("\nElements of the list:\n"); while(temp!=NULL) { printf("%d\t",temp->info); temp=temp->next; } } system("pause"); system("cls"); main(); }[/CODE] the following code is use to merge two linked list into one and … | |
Hello. i was trying to solve this problem: [B]You’re given an array containing both positive and negative integers and required to find the subarray with the largest sum (O(N)). Write a routine in C for the above. [/B] i was able to find the largest sum. However,i had little trouble … | |
My application is testing devices connectivity using ping (ICMP) functionality. It is working fine for all devices but for a particular device that is CISCO wireless controller it is not able to ping the device. I am able to ping the device through command prompt but when i debug my … | |
I have this code: Note: boom.ok[1][0] has the character "a" while boom.ok[[tempr[0]][0] contains the string "ay". [CODE]if ( strcmp(&boom.ok[1][0],&boom.ok[[tempr[0]][0]) == 1) printf("Hello"); if ( strcmp(&boom.ok[1][0],&boom.ok[[tempr[0]][0]) == 0) printf("Hello");[/CODE] None of these statement prints hello. Why? | |
C program to replace all the letters of a string with all 26 alphabets and to do permutations to all the substituted ones and finally store the resulted strings in a file.. please help me out in fixing this situation.. To be clear. let me quote an example: If i … | |
i m having trouble with updating the fie. every time the code is executed, the variables are not retrieved from the file and start from the scratch. moreover, the file is not updated. plz reply | |
Hi, so I have this assignment to create a scheduling algorithm, I tried looking everywhere for help on how to create one and the closest one was here, where I found a great source code, yet I tried to modify it with my assignment variables and I created some nasty … | |
[CODE]void alternate(char wordWord[][MAX],char wordVar[],int word[],int i,int j, int k, int l) { char ang[4],si[3],ni[3],ay[3],sa[3],kay[4]; int X,Y,Z1,Z2; strcpy(ang,"ang"); strcpy(si,"si"); strcpy(ni,"ni"); strcpy(ay,"ay"); strcpy(sa,"sa"); strcpy(kay,"kay"); tokenize(wordWord,wordVar,word,i,j,k,l); if(wordWord[j][k] == ang[4] || wordWord[j][k] == si[3]) X = wordWord[j][k]; else if(wordWord[j][k] == ni[3]) Z1 = wordWord[j][k]; else if(wordWord[j][k] == ay[3]) Y= wordWord[j][k]; else if(wordWord[j][k] == sa[3] … | |
[CODE]#include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <termios.h> int main() { int fd; int wd=0; unsigned char buff[] = { 0x02, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x23, 0x01, 0x21, 0x03}; fd = open("/dev/ttyS0", O_RDONLY | O_NOCTTY | O_NDELAY ); if (fd == -1) … | |
why this code not produce any reaction on any command [CODE]#include<stdio.h> #include<unistd.h> #include<fcntl.h> #include<stdlib.h> void count(char c,char *fn) { int lc=0,wc=0,cc=0,handle; char ch; if(handle=open(fn,O_RDONLY)==-1) { printf("File %s fail to open",fn); return; } while(read(handle,&ch,1)!=0) { if(ch==' '||ch=='\n') { wc++; }else cc++; } if(ch=='\n') { lc++; } close(handle); switch(c) { case 'c': … | |
I want to write this function integerPower(base, exponent) that return the value of base^[I]exponent[/I] For instance integerPower(3, 4) = 3*3*3*3 The function has two parameters my question is how can I use the for loop to control the calculation? It's not that hard to use the for loop when the … | |
So I'm fairly sure I have everything in the correct order, it compiles correctly, but when I try to run I just crash after the first Employee ID input. I've tried all i can think and have searched the web yet can't figure out why it crashes. [CODE] #include <stdio.h> … | |
i am working on a program to find the factorial of a number of any length. i have used an integer array to store the digits of the result. the problem is that i am unable to store more than 32000 digits in the array. if i give a larger … | |
in test function the for loop work fine but printf(num[0])is getting 0. does any one know why? [CODE] int main(void) { char num[20]; num[0] = '3'; num[1] = 'a'; void test(num); } void test(char num[]) { for(a = 0; a < 20; a++) { printf("%c",num); } printf("%c",num[0]); } [/CODE] | |
does any one know why my for loop work fine but printf("%c",num[0]); get me 0? [CODE] void test(char[]); void test2(char[]); int main(void) { char num[10]; test(num); test2(num); } void test() { num[0] = '1'; num[1] = '2' } void test2(int num[]) { for(a = 0; a < 10; a++) { … | |
What is meaning of "nature of entity"? e.g. kind of function, global variable? Is there any code to check it? Also, how to detect the memory section in memory map? e.g. environment, command line arguments, code/, global initialized data, global uninitialized data, stack, heap etc. Is there any code to … | |
serial port problem is occuring,,, pls guide on the same as i new to this,,, [CODE]#include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <termios.h> int main() { int fd; int wd=0; unsigned char buff[] = { 0x02, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x23, 0x01, … | |
hi all can i know how to find greatest of two numbers? the condition is we should not use any comparision operators.. thanks in advance | |
Hi,im making a console application,i would like certain printf:("") to have different colour than the others,is that possible? | |
[CODE]#include <stdio.h> #include <stdlib.h> int main () { int i,n,big; int * pData; printf ("Amount of numbers to be entered: "); scanf ("%d",&i); pData = (int*) calloc (i,sizeof(int)); if (pData==NULL) exit (1); for (n=0;n<i;n++) { printf ("Enter number #%d: ",n); scanf ("%d",&pData[n]); } big=pdata[0]; for(n=0;n<i;n++) { if(big>pdata[n]) { big=pdata[n]; } … | |
what is the use of malloc,calloc,realloc ?? i studied i didnt get proper knowledge .why instead of this why cant we use array??? | |
I'm currently working on a dictionary library in C and would like to start using struct's for easy assignment. Now, I have several functions that need to be a member in said struct's. I have it working well using pointers, but my only problem is that I would like to … | |
hi there im wondering about the difference between: int nr; if(!((nr--)%5)){...} if(!((nr--)%5)){...} and: int nr; if(!(--nr)%5)){...} if(!(--nr)%5)){...} is it right that in case 1 nr will be decremented after true/false comparison and in case 2 in advance? assuming nr=123456; in case 1 it would be true for second if.... and … | |
[CODE]#include<stdio.h> struct rec { int i; float PI; char A; }; int main() { struct rec *ptr_one; ptr_one =(struct rec *) malloc (sizeof(struct rec)); ptr_one->i = 10; ptr_one->PI = 3.14; ptr_one->A = 'a'; printf("First value: %d\n", ptr_one->i); printf("Second value: %f\n", ptr_one->PI); printf("Third value: %c\n", ptr_one->A); free(ptr_one); return 0; } [/CODE] … | |
hi guys,i was trying to make user able to make selection again when they make an invalid input, but when i run this code,it just doesnt work that way,it goes printing the same line like crazy...did i do something wrong? [CODE] int main (void) { //Local Declarations int menu; //Statements … |
The End.