15,552 Topics

Member Avatar for
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
330
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
Member Avatar for P

> I am supposed to create a chain of N processes, where N is the command line parameter. Each process creates a child process, prints out its own PID and its parent's PID, and then waits for its child to terminate by calling the wait() function. #include <stdio.h> #include <stdlib.h> …

Member Avatar for P
0
166
Member Avatar for Ajay_12
Member Avatar for jnneson

Hello Sir/Ma I am a self learning buddy, I recently finish a book "Programming in C" language. I will like to know how I can develop mt skill and learn more... please help

Member Avatar for jnneson
0
132
Member Avatar for anumash

I have the following code: It gives me a segfault when I modify any element in the character string. Why is that? The first two statements print fine but as soon as I modify the value of any element in the character string it gives me an error! I have …

Member Avatar for rubberman
0
281
Member Avatar for shifiya

A super-intelligent species of coconut-eating tropical bird has decided to develop a scenic ight path roughly following the perimeter of the island that they inhabit. Owing to the impressive energy con- sumption of their overdeveloped brains, these birds can only afford to y in straight lines from one coconut tree …

Member Avatar for iamthwee
-1
147
Member Avatar for Matt_15

//This is an example, coding not complete. Say main runs the function add, int add adds two random numbers and int random gets a random number from the array. By keeping 3 functions, how would I pass b and c to int add? Right now b and c are undeclared …

Member Avatar for deceptikon
0
255
Member Avatar for coolbeanbob

I've spent hours, an embarrasing number of HOURS on how to read a text file into a program. The requirements have shifted, but still. I hate you C. You and all your pointers. The text file is a matrix, but with the first line being the number of rows. See …

Member Avatar for deceptikon
0
171
Member Avatar for Habib_7

hi.I need 8 search engine for my school.can you give me just the name of those algorithm (except binary search and linear search).

Member Avatar for deceptikon
0
106
Member Avatar for manofprogram

I do not know how to open audio, video, or picture files and modify there contents. Are accessing and updating those types of files the same as accessing and updating notepad text files with extension .txt?

Member Avatar for ravenous
0
95
Member Avatar for ms95

i want to implement a kind of malloc and free function for a course project , now i have done something but i dont know whats the problem with access violation in this line : head->next = (struct block_meta *) allocate(sizeof(struct block_meta)); i'd be glad if someone can help me …

Member Avatar for ms95
0
344
Member Avatar for manofprogram

I want to know if my display adapter has been accessed by a keylogger or any other program capturing my screen images. Do I need to access my CPU, display driver, or computer memory to decide if the display adapter has been accessed? How can I find out what program …

0
82
Member Avatar for habib_6

Hi,I,m writing puts()function and I want to know that I which situations it returns EOF I know that when there is an error it return EOF but whad does it mean. can you give me an example?

Member Avatar for rubberman
1
111
Member Avatar for programmingman

I want to write code to see what applications access device drivers on my computer. The drivers are disk, display, audio, keyboard, etc. Can someone introduce me on how to do this?

Member Avatar for manofprogram
0
106
Member Avatar for kent.johnstone_1

In the following code I'm trying to make "SRAM", "FRAM", "EEPROM", and "FLASH" constants, MEM_TYPE an 8-bit variable that can be changed by other programs. The pointer should be pointing to MEM_TYPE. I'm getting a error under uint8_t (defined as BYTE elsewhere in an included file), "*", *and enum which …

Member Avatar for Nutster
0
242
Member Avatar for Larry_6

I'm writing a c code in order to dynamically create a sturcture like this: 1st -> 5 -> 7 -> 2, then 2->5(there is an arrow beneath 2 and link it back to 5) the data is below: struct node { int value; struct node *next; } Here is what …

Member Avatar for David W
0
238
Member Avatar for Akhila_1

Hey all, I want to learn C programming . Can you please guide me? (From where the software to be downloaded, Tutorials etc.) Thanks Akhila

Member Avatar for vegaseat
0
151
Member Avatar for samuel1991

Hi all, I have a question on how to reverse an integer array **recursively** with only 2 paramters. #include <stdio.h> void reverseAr(int ar[], int size); int main() { int size; //Array size int ar[100]; //The array itself int i; //Index to be read in the array int numbers; //User input …

Member Avatar for David W
0
262
Member Avatar for negru

Can someone explain this code step by step: #include <stdio.h> #define MAX 10 int main() { char niz[MAX][MAX], c = 0; int d = 1, x = 0, i, j; do scanf("%s", niz[x]); while (niz[x++][0] != '0'); { float* pf; int xx, *pi = (int*)&niz[0][7]; xx = ((*pi) & 0x41000000); …

Member Avatar for rubberman
0
192
Member Avatar for brandon66

Hello everyone~! I have a text file with integers on every line like: 2397 4013 9382 5995 4961 9961 1535 146 8153 3877 5872 2690 9731 8060 8452 7873 1109 4152 7256 2437 6815 2032 2473 1090 5674 6096 7868 422 My problem is: Im not sure how to store …

Member Avatar for brandon66
0
191
Member Avatar for zaxo311

I have to write program in c linux for operating systems class - communicator using fifo which has to work like that: ./Speak create name (to create user) ./Speak send from to (to send msg from user to user) ./Speak history name (to read all msgs sent to user Every …

Member Avatar for kdusyared
0
169
Member Avatar for lewashby

[Linux & gcc] I'm taking C courses and pluralsight.com and I'm both getting an error with a program I got from one of their videos as well as having some trouble understanding something in the code #include <stdio.h> #include <ctype.h> int main() { char message[] = "Hello world!"; for(char *p …

Member Avatar for TalhaMoazSarwar
0
210
Member Avatar for sdtechi

#include<stdio.h> main() { int m1, m2, m3, m4, m5, per; printf("Enter marks in five subjects"); scanf("%d %d %d %d %d", &m1, &m2, &m3, &m4, &m5); per=(m1+m2+m3+m4+m5)/500*100; if(per>=60) printf("First division"); else{ if(per>=50) printf("Second division"); else{ if(per>=40) printf("Third division"); else printf("Fail"); } Enter marks in five subjects 100, 100, 10, 50, 60 …

Member Avatar for TalhaMoazSarwar
1
231
Member Avatar for nacedo

Lets say I want to write a very simple C program wich a is string passed with a pipe at my program and translate every letter to ASCII and store it in an array. I want to use less library as possible and not use malloc For example in a …

Member Avatar for TalhaMoazSarwar
0
202
Member Avatar for greg.lafrance.96

I am following Kernighan and Ritchie to learn C and my solution to exercise 1.19, to reverse a string, does not work. Intermediate print out indicates it is working, but the string is not reversed. Please help, and thanks. #include <stdio.h> #define MAXLINE 1000 // max allowed line length int …

Member Avatar for TalhaMoazSarwar
0
433
Member Avatar for Ctwo

Hello. Just dusting off my function knowladge in relation to pointers for refactoring in a larger project. Came up on this discrepancy. See my verbose debug output. Problem around for loop in function. Short post because adblock wiped my post form two times. :) #include <stdio.h> int mult(int x, int …

Member Avatar for TalhaMoazSarwar
0
198
Member Avatar for ryan.legow

I am trying to make a deck of cards and minipulate them in 3 files part 1, part 2, and header. In the header I am trying to make the deck so that it would be easy to call up in both part 1 and part 2. In part 1 …

Member Avatar for ryan.legow
0
2K
Member Avatar for csakthikumar

Hi Guys, I have wrote a small logic below which will calculate a value called MASK via which I can calculate the starting and ending number This logic works fine if A = 0x14000000 B = 0x14000064 void main() { unsigned long ulStartVal = 0x14000000; unsigned long ulEndVal = 0x14000064; …

Member Avatar for Nutster
0
143

The End.