15,551 Topics
| |
Can i change the array's rows length after i define it as constant or any other way? Can you under my code or explanation? [CODE]#include<stdio.h> #define CLASS_SIZE 20 //First define the array rows's length void main() { double gpa, average, highest, lowest; int student, rows, i, j; char grade[CLASS_SIZE][5]; //Wish … | |
This may be a rather simple thing to answer, but I am no programming expert. Let me explain my problem in detail: for this homework assignment I need to open up a file with simple text in it, format it so that each line is reduced to a certain number … | |
using the standard function in atoi() wont work. it gives me an error that says "assignment makes pointer from integer without a cast" this is sample of the code.. [CODE]struct integer* convert_integer(char* stringInt) { struct integer* convertedInt_1; char* stringArray3 = (char *) malloc (sizeof(char));; free(stringArray3); stringArray3 = stringInt; convertedInt_1->digits = … | |
Suppose that you have a structure defined as such. [CODE] typedef struct Deity { char name[80]; char religion[80]; int numAppendages; } Deity;[/CODE] And, suppose you have a pointer to a Diety structure. Deity* deityPtr; Assuming that at some point you allocate memory for a Deity structure, assign its address to … | |
Hi, I need help with this, I'm reading a txt file that has this format: 10,4,12,6,18,24,7,8,15,14,25,2 So far, I read the file using fopen ().Also, I used strtok () to split the string into tokens, but i don't know how store the tokens into an array. any ideas? thanks [CODE] … | |
Hi folks, I'm trying following code.. [CODE] #include<stdio.h> int calsum(int a,int b,int c); int main(){ int x,y,z,sum=0; printf("Enter the 3 numbers:\n"); scanf("%d%d%d",&x,&y,&z); sum=calsum(x,y,z); printf("The vlaue of sum is :%d\n",sum); return 0; } int calsum(int a,int b,int c){ int d=0; printf("The value of d is:%d",d); d=a+b+c; } [/CODE] ** (1) ** … | |
I have been working on this code for a while and I can't seem to get to work right. I have been trying to make a credit card validator program in c for a class assignment. Any help would be welcome. [CODE]#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <string.h> #include … | |
I used a multi dimensional array: [CODE]int grid[3][3];[/CODE] then I assigned all the variables in the array to the number 2 like this:[CODE] grid[0][0] = 2; grid[0][1] = 2; grid[0][2] = 2; grid[1][0] = 2; grid[1][1] = 2; grid[1][2] = 2; grid[2][0] = 2; grid[2][1] = 2; grid[2][2] = 2;[/CODE] … | |
This is a question from some book. When u run it u would get base address of the arguments provided that is, if u write in CMD "myprog one two three" then the address would be like 65521 n 65525 n 65529 Means equal byte consumption by all the arguments. … | |
Hi all! I am having trouble accessing dynamic information. I have used the malloc command to allocate the necessary memory for my struct. However, when I leave that function and enter a display function it says there is a problem accessing the information in the struct. I just had a … | |
| I've searched google and tried several different things but I can't figure out how to read strings into a two dimensional character array and also read doubles into separate arrays all from the same text file. Please provide any help you can and let me know how you might accomplish … |
[CODE]#include <stdio.h> #include <stdlib.h> #include <math.h> float f(float x); float df(float x); int main(){ float x=-0.7; int i=0; float y; do{ printf("f(x) is %f",f(x)); y=x-(f(x)/df(x)); x=y; i=i+1; printf("repeats %d",i); printf("x is %f",x); }while (f(x)!=0); return(0);} float f(float x) { return (x+pow(exp,-10.0*pow(x,2.0))*cos(x)); } float df(x) { return ((1-20*x*exp^(-10*(x)^2)*cos(x)-exp^(-10*(x)^2)*sin(x))); }[/CODE] | |
The problem ''Ask the user to enter a year and store it in an int. Then assign to a _Bool variable the value true if the year is a leap year. The leap year is any year whose number is a multiple of four. Take into account that years whose … | |
Hi.... I wrote a program for Quick Sort algorithm.... It is compiled fine....but it is giving a run time error i.e., Segmentation Fault.... I tried hard but couldn't find out what is that thing causing segmentation error in this program.... Please help.... I'm getting segmentation fault very frequently (i'm using … | |
I’m trying to use an Aug20th 2005, how to set file access time, here on DaniWeb. I need to modify the file times for a “C”, not C++, Visual Studio 5, console ap that I am working on. Here is the exact code for the project: [CODE]#include <windows.h> #include <stdio.h> … | |
Does USSD syntax include other characters other than "[B] * and digits[/B]". While [I]googling [/I] I have not found where it is explicitly explained. This is because I am getting ERROR while sending USSD which consists of spaces and : (column) | |
i want to write a program which display alert message whenever 15 mins are over.But i am not finding solution of my problem using waitforexit() or delay() functions. [CODE] #include<time.h> #include<stdio.h> #include<dos.h> #include<conio.h> void main(void) { time_t timer; struct tm *tblock; time_t t; //timeout=18000; /* gets time of day */ … | |
So I have been trying to implement piping in my own shell program so that I can actually understand what UNIX is doing. I'm very very close at the moment, but for some reason my program is going into an infinite loop when I pipe. I'm pretty sure my problem … | |
I don't really know what to ask here because the only indication I have that there is something wrong in my program is that nothing is showing on the screen. I'm loading a .obj model (it's just a cube, and i've checked all the verts/faces and they're all proper values) … | |
Hi all, I have this code here and I like to save all the messages into 1 text file name contimer.txt. I've tried to do [CODE] FILE *output fopen(output,"comtimer.txt", "ww"); [/CODE] right before the function Timer 1 and change every "printf" function into fprint_s(f, "Message", variables) but it does not … | |
the problem is if you increase buff size and also change the buff size in a3_fgets_2 function call to more than 15, the program will run in an infinite loop, Can anybody tell me why? Thanks [CODE]#include<unistd.h> #include<string.h> char * a3_fgets ( char * str, int num, int fd ); … | |
Hi Friends , This is Ganeshan . I Found the Below undefined errors when using Socket programming on Eclipse IDE . I don't know what to do ?. Kindly please help me in removing the Errors . [Linker error] undefined reference to `WSAStartup@8' [Linker error] undefined reference to `socket@12' Thanks … | |
hey me and my group are doing a project but we dont know how to use the file pointer (to export the C program to a text file and we dont know how to make it so the random generator makes our words go diagonal top left bottom left top … | |
[CODE]#include <stdio.h> #include <conio.h> #include <math.h> // +-*/ void readArray(int *a, int n) //fuctie care citeste un tablou { for(int i=0; i<n; i++) { printf("A[%i]=",i); scanf("%i",&a[i]); } } void printArray(int *a, int n) { for(int i=0; i<n; i++) { printf("%i ",a[i]); } } void patratPerfect(int *a,int n) { for(int i=0; … | |
if write/take a one space after ACCESS SPECIFIER in a scanf(), then why it takes extra inputs???????? e.g. scanf("%d ",&n); it will take numbers....instead of one? | |
i get this error every time i try to compile the code below. any suggestions --------------------------------------------------------------------------------------- Compiler: Default compiler Executing gcc.exe... gcc.exe "C:\Users\ndayala\Desktop\19266\main_random.c" -o "C:\Users\ndayala\Desktop\19266\main_random.exe" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" C:\Users\ndayala\Desktop\19266\main_random.c:9:22: sys/mman.h: No such file or directory C:\Users\ndayala\Desktop\19266\main_random.c: In function `main': C:\Users\ndayala\Desktop\19266\main_random.c:30: error: `PROT_READ' undeclared (first use in this function) C:\Users\ndayala\Desktop\19266\main_random.c:30: error: (Each … | |
I'm trying to do the third writer/reader problem with semaphore (as mention on wiki). But it's not working properly. First 16-element array seem to work properly. But after first, it got wrong. Even though I think I'm almost there, I can't find the error at all. My code is as … | |
Hi all, I have a question regarding an extern variable. ---test.c [CODE]#include <stdio.h> #include </home/peuceul/debug/test.h> extern int a; int print1() { printf("value of a in extern is %d\n", a); int a = 2; printf("value of a is %d\n", a); } int print2() { printf("value of a in second method is … | |
[CODE]#include<stdio.h> #include<conio.h> struct node{ int data; struct node *next; }; struct node *creat_list(struct node *start); void display(struct node *start); struct node *addatbeg(struct node *start,int data); struct node *addatend(struct node *start,int data); int main(void) { struct node *start=NULL; int choice,data; while(1) { printf("1.creat linklist\n"); printf("2.display\n"); printf("3.add at beg\n"); printf("4.adda t end\n"); … | |
I don't get it why my threads can't perform properly for writer/reader problem. I think something with the semaphore. but can't solve and online can't help me too. [CODE] semaphore mutex, read, write; void *reader(void *argv) { char buffer[200]; int readNo, i=0; do { sem_wait(&read); sem_wait(&mutex); sem_getvalue(&read, &readNo); fgets(buffer, sizeof(buffer), … |
The End.