15,552 Topics
| |
I'm learning to get used to the pointers in C and I have a question about them that I coudln't understand. Anyways, why this code gives segmentation fault? void print_arr(const char *p_array[]){ int index; for(index = 0; p_array[index] != 0; index++) printf("%s\n", *p_array[index]); } while the one without a '*' … | |
Here is a sample exam. What other kinds of questions do you think I could prepare before walking in there since all resources are permitted? Write a single program which contains functions to do the following steps. Each of these steps involve reading the file above and displaying some of … | |
I am trying to allocate memory for three string and print it to screen.but it isnt working .can anyone explain what's wrong here #include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char **name; int i; name=(char **)malloc(3 * sizeof(char *)); while(i<3){ name[i]=(char *)malloc(20 * sizeof(char)); } while(i<3){ scanf("%s",name[i]); } while(i<3){ printf("%s",name[i]); } … | |
Show 10 students data ( student id, father's name, phone number, mail id) in a file and write a C program to display the student's data whose id is given by a user through the keyboard. Please help me out in solving this program. I know how to read data … | |
I wrote a program, in which my code is checking the word entered by user and the word in a file. If the words are not same, the file is deleted. i closed the file using **fclose(fp)**, (where fp is file pointer) and to delete the file i used **system("del … | |
what is top down in writing an algorithm ? and what are differences of it and stepwise ? | |
urgently need programms on encyption and decrypation on C language | |
# copy string into a structure # all i am trying to do here is to copy a string input given by user into an arry decleared inside a structure.but my code is not working. anyone please explain to me why this code isnt working #include<stdio.h> #include<string.h> typedef struct{ int … | |
error in ma program it shows the last digit twice. #include<conio.h> #include<stdio.h> int main() { int fib(int); int n,c,a=0,b=1; printf("enter a number: "); scanf("%d",&n); printf("%d %d ",a,b); c=fib(n); printf("%d ",c); getch(); } int fib(int n) { int a=0,i,b=1,sum; for(i=0;i<n-2;i++) { sum=a+b; a=b; b=sum; printf("%d ",sum); } return(sum); } | |
hey i have a project on logic circuit simulation.i don't know how to include basic gate images in my code,so that it is displayed with the chosen gates output.i have jgrasp c_compiler.so plz help me out. #include<stdio.h> int And(int a, int b); int Or(int a, int b); int Not(int a); … | |
# copy string into a structure # **all i am trying to do here is to copy a string input given by user into an arry decleared inside a structure.but my code is not working. anyone please explain to me why this code isnt working** #include<stdio.h> #include<string.h> typedef struct{ int … | |
sir i need c code to generate random numbers between 1 to 100 and where the user can select the range(say 50 random numbers between 1 to 100 or 20 random numbers from 1 to 100 ) such that generated random sequence are not psuedo random numbers when it is … | |
# 2-D string implementation # ## i am new to c.anyone please help me why this code is not working## #include<stdio.h> #include<stdlib.h> #include<conio.h> typedef struct{ char name[2][10]; }college ; int main() { college student; student.name={{"james"}, {"carter"}}; printf("%s %s ", student.name); getch(); } ** | |
**This is a sample text file. Your program should add a space after the following comma,and after this comma,but not after this comma, because there is already a space. Similarly, it should add a space after the following fullstop.And after this fullstop.But not after this fullstop. Goodluck.** # I want … | |
This is the code do look at it. I just want change it in switch statement. will stuck in it. it is unix code. commands[0] = (char *)"ls"; params[0] = (char*)0; commands[1] = (char *)"who"; params[1] = (char*)0; commands[2] = (char *)"date"; params[2] = (char*)"+%d/%m/%y"; commands[3] = (char *)"ps"; params[3] … | |
Hello. I am writing a program that computes net pay by the user entering in hours and payrate. There can only be one decimal, two numbers after the decimal, and no letters. When payrate is entered wrong, it displays the correct error message. For hours, it doesn't even though it … | |
Hi im using turbo C++ compiler and im currently learning C. Iand have an assignment that i need to make a program that solves mathematical problems. Well first is that. the user would have to input a problem in whichever way the user wants. like this example: (5*2)+2-2/2 it could … | |
The "r" function works well! #include <stdio.h> #include <string.h> #include <stdlib.h> int main(void){ FILE *file_r, *file_w; int c; char fileread[40]; char filewrite[40]; printf("Enter filename to be copied: "); gets(fileread, 40, stdin); fileread[strlen(fileread)-1] = '\0'; file_r = fopen(fileread, "r"); while(file_r == NULL) { printf("Invalid file, ealnter again!"); fgets(fileread, 40, stdin); fileread[strlen(fileread)-1] … | |
Anyone can help? What is the codes to let the word in twinkling motion? I am in trouble of it >< | |
I'm new to win32 application building using C. I'm using DEV C++ and I'm able to get a window, by using the "windows application" icon in DEV. I want to know how to display our text on to the window??? That'll be very helpfull! This is the readymade code generated … | |
a) Write an algorithm to add and multiply two large integers, which cannot be represented by built-in types. b) Write a “c” function to find recursively the maximum and minimum element of an array A of size “n” elements. Find also the number of comparisons required for this. a) Write … | |
why in a calculator program using command line argument multiplication not done???? in Gcc | |
I am trying to access a string. wchar_t *str; char *Pname; FILE *fp; str = somefunction(); Pname = str; fp = fopen ("/tmp/test","a+"); fprintf(fp,"%s\n",Pname); fclose(fp); str actually contains "ABigName", but the file simply contains the first letter, "A". | |
Okay I am trying to write a program where a parent process creates three child processes. Also waits for each of them to finish. Here is my code: [code] #include <stdio.h> #include <unistd.h> main() { int i; // create 3 child processes for (i = 0; i < 3; i++) … | |
Hi, I've been having some problems with the getchar() statement. When I put it in a loop (to make an interactive input), I can't get user input anymore from within the loop. Even the following simple program doesn't work: [code] #include <stdio.h> #include <stdlib.h> int main(void) { char response, text[255]; … | |
This is a simple calcualtor program. What I don't understand is how I could modify it so that the calculation parameters could be intered from cmd. I don't understand how the argv and argc really work in this case. Do I need to replace all the ints with argv or … | |
Hi, I have a function which returns a pointer to array with data: `float * EZ_MATH::EZ_GE_BY_ME() { ... }` Now, how can I access this data? This doesnt work: `float * memA = temp_m.EZ_MATH::EZ_GE_BY_ME();` `ofstream output("out_file", ios::out);` `output << memA[0] <<endl;` `output << memA[1] <<endl;` Help! | |
Hi , I have this code for win xp `char NotesDir[] = "\\Program Files\\notesw32"; char Fname[] = "C:\\Program Files\\notesw32\\notes.ini"; char Bakname[] = "C:\\Program Files\\notesw32\\notesini.bak";` But for win 7 , these files will be present in c:\\Program Files (x86) folder. How do i make sure my code works for both xp … | |
#include<stdio.h> #include<conio.h> int main() { long double p=778.567; printf("%Lf",p); getch(); return 0; } it's output is : -115403.... something... why is it so ? | |
The following short program is taken from a book in numerical analysis (by Mircea Andrecut). It's about bisection (very simple): #include<stdio.h> #include<stdlib.h> #include<math.h> double f(double x) { return x*x-3; } double bisection(double f(double), double a, double b) { double epsilon = 1E-7, x; int kmax, k; if (f(a)*f(b) > 0) … |
The End.