15,550 Topics

Member Avatar for
Member Avatar for Mayukh_1

I have these files.. **str.h** #ifndef _str_h_ #define _str_h_ struct STRSTR { char* MainStr; char* SubStr; }; char* str_str(int, int, struct STRSTR* sample); void init(char*, struct STRSTR* sample); #endif /* _str_h_ */ **str.c** #include "str.h" #include <stdio.h> void init(char* str, struct STRSTR* sample){ sample->MainStr = str; } char* str_str(int index, …

Member Avatar for Mayukh_1
0
305
Member Avatar for s.inayath123
Member Avatar for chester1908

Hello, i was wondering if i could get an opinion on the following code as it is giving me a headache: int counter = 498853097; int k = 0; clock_t start, end; float seconds1,seconds2; start = clock(); for (int i = 0; i < counter; i++) { k++; } end …

Member Avatar for chester1908
0
290
Member Avatar for JOHN-shirley

Please can someone help me and show me where i am going wrong ? The code below is not an assignment or homework it is something i am tryigng to do for work. The code scans a text file ( attached ) and stores 10 x 5 digit ints into …

Member Avatar for Moschops
0
170
Member Avatar for kayleigh0411

I am creating a doubly linked list and printing a backwards function. Everything is working great in my code, but when the function is printed in reverse, I need it to say NULL at the end, as it does going forward. When I put puts("NULL") (line 193) it splits up …

Member Avatar for kayleigh0411
0
279
Member Avatar for negru

How to concat multiple strings in C? I have a function for concat two strings: char* concat(char *s1, char *s2) { char *r, *t; int d1 = -1, d2 = -1; while (s1[++d1]); while (s2[++d2]); t = r = (char *)calloc(d1 + d2 + 1, sizeof(char)); while (*t++ = *s1++); …

0
130
Member Avatar for nitin1

I have come across one question: find the size of two 2-D arrays when double pointers are given for them.Then find, if we can muliply these two matrices(those mathematics rules). finally we have to multiply the matrices. I have asked this question(small part of this question) earlier also. someone answered …

Member Avatar for Moschops
0
187
Member Avatar for Gà_1

**Problems 1: Spiral matrix - Advanced** Source of the problem: [Here (not in English)](http://www.spoj.com/PTIT/problems/BCACM11B/) Spiral matrix is formed by filling number 1 in 1st row 1st column, after that, filling with increasing number by clockwise, example: 1 2 3 4 5 16 17 18 19 6 15 24 25 20 …

Member Avatar for tien.nguyen.3532507
0
369
Member Avatar for anumash

I am having a confusing time with understanding arrays and variables because of this reasoning: Variables are aliases for memory locations and array name is the address of the first element of the array then why are variables not accesssed as *i whereas the first element of array is accessed …

Member Avatar for Schol-R-LEA
0
154
Member Avatar for mridul.ahuja

I came across this code of [firefly algorithm](http://en.wikipedia.org/wiki/Firefly_algorithm) and need to use it in my major. If any of you could explain the working of the functions, it would be of great help to me. Thanks in advance. #include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<time.h> #include<string.h> #include<memory.h> #defineDUMP 1 #defineMAX_FFA 1000 #defineMAX_D …

Member Avatar for Schol-R-LEA
0
284
Member Avatar for JohnMcPherson

Hello, I am trying to compare a double to be within various ranges, but the comparison is not working correctly. Rounding precision is not a concern, because if the value will match the boundaries so rarely, and it is rounding up to the higher range is acceptable. Below is the …

Member Avatar for JohnMcPherson
0
218
Member Avatar for akane.mikazuki
Member Avatar for Anil2447

Here is the code for [B][COLOR="Red"]Insertion Sort, Bubble Sort and Selection Sort[/COLOR][/B] [B]Insertion Sort[/B] [CODE] #include <stdio.h> main() { int i,j,key; int a[5]={5,2,3,4,1}; for(i=1;i<5;i++) { key=a[i]; while(i>0 && a[i-1]>key) { j=a[i]; a[i]=a[i-1]; a[i-1]=j; --i; } } int k; for(k=0;k<5;k++) {printf("%d ", a[k]);} printf("\n"); } [/CODE] [B]Bubble Sort[/B] [CODE] #include <stdio.h> …

Member Avatar for Talha_5
0
9K
Member Avatar for zxz

hi everyone , i have worked on this 2 days now and cant find my mistakes , the program runs but it stops ( waiting ) after i enter 3 or 4 . can anyone help me where are my mistakes please? thanks allot. the program should do the following …

Member Avatar for zxz
0
239
Member Avatar for negru

I have a C code written in Visual C++ 2010 environment and it compiles without errors. When I try to debug it, after the line with scanf() function it goes to unknown scope and stops the process of debugging. How to fix this? Thanks for replies.

Member Avatar for Moschops
0
219
Member Avatar for negru

Which tool for code analysis is the best for complex C programs? I use GCC debugger with Code Blocks 13.12 Thanks for replies.

Member Avatar for Moschops
0
197
Member Avatar for riahc3

Hey I was wondering how to generate a Windows popup in C. I mean by "Windows popup" as in (for example) when you do a net send message to a PC, a simple Windows popup comes up on the PC you sent the message to with the message. How can …

Member Avatar for tirumalai
0
9K
Member Avatar for negru

I need help with recursion function. It prints all the prime factors of an input number. My question is how to modify function so that START-GOTO is replaced by a loop? Here is the code: int f(int n,int i) { start: if(n==1) goto start; if(n % i == 0) { …

Member Avatar for Moschops
0
170
Member Avatar for ms95

hi guys i've written an bare OS and now im trying to go a little furthur and create a very simple GUI for it . but i have no idea how to create such a thing . my os is running in text_mode though i can change to some other …

Member Avatar for Schol-R-LEA
0
3K
Member Avatar for kayleigh0411

I am trying to implement a test program to describe what this function does: int mystery( const char *s1, const char *s2 ) { for( ; *s1 != '\0' && *s2 != '\0'; s1++, s2++ ) { if( *s1 != *s2 ) { return 0; }//end if }//end for return …

Member Avatar for rubberman
0
301
Member Avatar for Habib_7

for example i have a void pointer : void *pt; int k=80; pt=&k; now i want to incement it by one byte ,is it just enough to use (++(char*) pt) or I should use (void*)(++(char*)pt) by this asssumption that i wnat to cast it again to int ,char ,... later.

Member Avatar for Habib_7
0
117
Member Avatar for Vahid_1

Hello, I'm just started to study malloc and realloc, so i just wrote this program to copy two string from user input and consenterate them. then ofcource print it. #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char *str = malloc(3) gets(str); int sl = strlen(str); str = realloc(str, …

Member Avatar for sepp2k
0
218
Member Avatar for Habib_7
Member Avatar for negru

Hi. I need help with this program: Example input: 2 4 6 -1 7 3 -2 1 Output: 3 3 (longest series of even is 3, longest series of positive is 3) Here is the code: #include <stdio.h> int even(int x) { return x % 2 == 0; } int …

0
92
Member Avatar for jai_5

I am printing in my c program which deals with structures but not able to understand why getting a small box containing 0001 in box.printing is fine but the uneccessay boxes are coming. I dont know what they actually mean.

Member Avatar for jai_5
0
339
Member Avatar for ryan.legow

So I am trying to make my own version of chmod using C, the modifications are to make lowercase add permissions while uppercase remove permissions (instead of using + or - to add and remove). Also, I am trying to print a help message and exit if the command cannot …

Member Avatar for ryan.legow
0
265
Member Avatar for manofprogram

I have a simple c program outputing a message asking for user input. Then a scanf function reading in user input. When the program is run, the program execute the scanf function first before printf is executed asking for user input. What is wrong with the program? int main () …

Member Avatar for deceptikon
0
126
Member Avatar for negru

I need to create dynamic string by given format(%d,%s,%f,%lf,%c) using variable number of arguments in function. This code gives me an error(main.exe has stopped working): #include<stdio.h> #include<stdarg.h> #include<string.h> #include<stdlib.h> char *form(char *format,...); char *form(char *format,...) { char *res=(char *)calloc(1,1),val_int[12],*pos_int,*val_str,*pos_str,*val_float,*pos_float,*val_lf,*pos_lf,*val_char,*pos_char; va_list args; va_start(args,format); do { pos_int=strstr(format,"%d");pos_str=strstr(format,"%s");pos_float=strstr(format,"%f");pos_lf=strstr(format,"%lf");pos_char=strstr(format,"%c"); if(pos_int && (!pos_str || pos_int …

0
146
Member Avatar for Larry_6

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main() { char buf[15]; char *buf1 = "CE_and_IST"; char buf2 = 'z'; int fd = open("myfile", O_RDWR); lseek(fd, 10, SEEK_SET); int n = read(fd, buf, 10); printf("%d\n", n); n = write(fd, (const void *)buf1, 10); printf("%s\n", buf); …

Member Avatar for davidnelson4911
0
329
Member Avatar for CodeWarrior14

I need to allocate memory to a pointer variable passed by parameter. #include <stdio.h> #include <stdlib.h> typedef int* PTR_VALUE; int initialize(PTR_VALUE value_array) { value_array = (PTR_VALUE)malloc(sizeof(PTR_VALUE) * 94); return 0; } int main() { PTR_VALUE pValue; initialize(*pValue); printf("%d", pValue); gets(""); return 0; } but I get an error when I …

Member Avatar for CodeWarrior14
0
222

The End.