18,490 Topics
Hi I was ask to do a code in c wich read the contenent inside a txt file and display it then after display it they wan't me to tokenize those command and interpretate them in c. I have no experience in c if someone can show me how to …
Hey everyone. I really need some help with my code for class. Here is the prompt : Write a program to manage a dictionary. The dictionary should be stored on a text file named diction.txt and consist of an alphabatized list of words, one per line. When a user enters …
hi i really interest in C game programming. i looked online for tutorials but they seem confusing. I am using c for one year, but i have no knowledge of game programming. could any one tell me where should i start and what is the best language for game programming. …
so i fork n process: for(i=0; i<numOfProcess; i++) pid == fork(); if(pid == -1) //error handling if(pid == 0){ //child, do something exit(0); } else{ //parent //i want to wait till all children are done before continue..how? //i tried wait(NULL), and waitpid(pid, NULL, 0) //but both wont work..? //........... //something …
I was told to use bubble sort to sort the arrays. what i need to do is read in one array and have to sort into the other array but i haven't been able to figure it out here's the code i have so far. i've been trying to manuplate …
I am so confused on how to tell a run time of a algorithm. so i came up with some ex for me to understand. could any one tell me if i am find the run time right plz. ex1 - run time for this loop is O(n)? bc it …
ok so I had to do a program that represents numbers from different radix to some other radix... The part I got stuck is the following: i.e. I want to convert 123.625 (radix 10) to radix 3. The output is 11120.1212121212121212..... any ideea of a pseudocode/C code to detect whenever …
hi Am trying to write a C-code that multiply two matrices but i want the elemnets of every matrix is random number using time function main() { srand ( time(NULL) ); int m1[10][10]; m1[10][10] = rand() % 10; scanf("%d%d",&r1,&c1); scanf("%d%d",&r2,&c2); if(r2==c1) { . . . . } this is the …
Hello everyone!! I have a problem about memory allocation, i use calloc() to initialize all elements in array to be zero. This is my code: #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <time.h> #define sizes 1200 main() { double** arr; int m[sizes]; int i,j,k; srand((unsigned)time(NULL)); arr= (double **) calloc(sizes,sizeof(double*)); for(k=0; …
i need help finding the low value in an array after reading file with numbers. With my program I am to assume that the size an array is 100 even if only 10, 31, 50 spaces are taken up. The problem im running in to is when i iniztialize the …
Hello. I am trying to accept a paragraph from the user in C using codeblocks. But, with the scanf statement, the program stops accepting once i hit space. Is there some way to get around this problem?
I am trying to compute 2x-x+4x, so the answer should be 5x. but i am not sure how to get started. The "x"'s are messing me up. I am thinking of using for loop and replace x with '\0'. and than add or sub starting from left to right. but …
hi.. lately i had this problem when i try to build in codeblocks.. Debug" uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?! Skipping... Nothing to be done. and i tried to install it again and again with different versions.. but it still …
Dear All, I am trying to write to a file as below. But my file shows empty what could be wrong here? const char *dataFileName = "data.dat"; FILE *ftdata = fopen(dataFileName,"a+"); fwrite("TEST",1,2,ftdata);
#include<iostream.h> #include<conio.h> void main() { int z[33]; clrscr(); cout<<"Enter any Password (32 character max): "; for(int i=0;i<33;i++) { z[i]=getch(); if(z[i]==13) { break; } cout<<"*"; } cout<<"\nYou entered : "; for(int j=0;j<=32;j++) { if(z[j]==13) { break; } cout<<(char)z[j]; } getch(); }
Hello.Got a problem with a binary tree again,i have made a visual printing but the problem is that it prints only completed tree,so if it is not full it crashes,is there a posibillity to add some extra print to value NULL,so after one right or left leave won't have value(NULL) …
How can we convert a string to int without a standard lib the string termination can be '/r'
i need help with merge sort. struct List_A { int data; struct List_A *next; }; struct List_A *head; void merge_sort(struct List_A *); int main(void) { ....lets say i have a list build --- (list_A = 4,3,2,5) merge_sort(List_A); } void merge_sort(struct List_A *head) { struct List_A *cur_one; struct List_A *cur_two; if(head …
Hi all, Having a little trouble with assigning values to an array within a C struct. Unfortunately i cannot assign a size to the array as i am reading values to an array to be stored, and the size is relative to the other values in the struct passed to …
how do you insert in linked list. this is that i have. struct node { int data; struct node *next; }; struct node *head; void insert(struct node*, char*, int); int main() { int data; struct node *List_A = NULL; insert(&List_A, %data); return 0; } void insert(struct List_A, int data) { …
I was trying to assign values from a txt file to my program with the following code: #include<stdio.h> #include<conio.h> #include<string.h> int main() { float c1, c2, c3, c4, c5, c6, c7, c8; char d1[4], d2[4], d3[4], d4[4], d5[4], d6[4], d7[4], d8[4]; FILE *rate; rate=fopen("rates.txt", "r+"); fscanf(rate, "%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f", &d1, &c1, &d2, …
Can someone guide me how can I use scanf for a structure? [CODE]const int IDLEN = 30; const int POLARITYLEN = 3; const int MAXSTOCKITEMS = 10; struct TransistorRec { char manufacturersID[IDLEN]; char polarity[POLARITYLEN]; float power; float gain; int stock; }; typedef struct TransistorRec Transistor; struct StockRec{ int size; Transistor …
Can someone help me make a code for a username and password program where the usernameand pass is stored in a txt file. I've tried many things but I still can't make it work. The text file in question has the username password and user type separated by tabs and …
Reading a character from the keyboard keeps giving me problem. When I do a gcc -o progname progname.c and ./progname, and press enter, it doesn't stop to receive the character. How can I correct this ? Code blocks are created by indenting at least 4 spaces ... and can span …
Help me please to find the problem in my code: Here is the error that I'm getting: serg@serg-PORTEGE-Z835:~/c$ gcc string_finder.c -o string_finder string_finder.c:4:5: error: conflicting types for ‘getline’ /usr/include/stdio.h:671:20: note: previous declaration of ‘getline’ was here string_finder.c:22:5: error: conflicting types for ‘getline’ /usr/include/stdio.h:671:20: note: previous declaration of ‘getline’ was here …
I'm looking for feedback on my code. I wrote a custom memory allocator (out of pure boredom) that is faster than the STD one (malloc, free). It's pretty simple in the way it works, it has a base block of memory which is where everything is allocated from, and it …
Hi friends! I'm new to libcurl programming in C. I cant find any libcurl tutorial on the web.Also i tried [the official one](http://curl.haxx.se/libcurl/c/) but i cant understand it because its not elaborate. So please help me with the tutorials/resources on libcurl programming in C. Thank you.
hi guys!! The purpose of the program I am trying to do is to have an input number of 6 digits typed in and this should then be printed as an hour minute second format. for example 123456 would be 12:34:56 This is what I have but it isn't working …
actually, i don't know where to post this thread. but i know the people available on daniweb.com have much knowledge. will you please tell me that how to start writing proposal. i have spend 2 full days on PC reading about G-SOC but still i am not getting how to …
les say we have a binary file. and 1st letter is 3. how do i take 3 and put it into a char ar[]. what i did was if(fread(ar, 1, 1, fine)) { }
The problem I have and can't understand is that I receive a segfault when trying to close the second file (fclose(ofp)). Input file is a xml file that will generate food for output file. At present time, input file is being read for parsing but no output for outfile is …
actually, i want to calculate 2^60000 in 1 second. i have tried a way but it is giving output in specified time for 1000 power only.(i have used arrays to store a one integer). will you please give me a hint only how to do that ? [B][I][U]"I AM NOT …
Why is it that this won't work instead of using atoi ? `Inline Code Example Here` #include<stdio.h> int main(void) { printf("%d",(int)"10"); return 0; }
char *ar[5]; //Array of pointers let say char * ar[5] contain: ar[0] = "cat"; ar[1] = "desk"; ar[2] = "desk" ar[3] = "zoo"; ar[4] = "cat"; how i want to get of any same strings. so in end ar should have the value "cat","desk","zoo". this is what i have so …
I am working on a recursive flood-fill function with 4-connected neighbours as part of a drawing application program. However, my attempts keep resulting in the program crashing. I am coding in C, however I will just post pseudo-code of my algorithm. I am hoping somebody can help me see what …
hi, i have a small problem with my program: int main(int argc, char *argv[]) { int ende; int modus; short x; short y; mkdir("maps"); while(1==1) { cls(); //some printf's char enter=0; while (enter != '\r' && enter != '\n') { enter = getchar(); } system("cls"); ende=0; modus=0; //some printf's scanf("%d",&modus);fflush(stdin); …
hello, i wanna ask if somebody can help me with this problem. First code: #include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]){ if(argc>1) { int i=1, zmnozek=1; zmnozek=atoi(argv[1]); for(i=1; i<argc; i++) { zmnozek*=atoi(argv[i]); }; printf("Rezultat: %d\n",zmnozek); }else { printf("Nepravilen vnos!\n"); }; return 0; } And there is the problem: …
Can someone please answer this for me as i cant do this practice question Thank You. 
Hey, I'm funkey100 and I'm new at this community. I know HTML, CSS, Java, JavaScript, a little C, C++, Action Script 3 and I think that's it. I play WoW and some other games but I'm not addicted. Plus, like all cool people, I go to 9gag! Well, there's more …
I have been trying to explore the source code of the getcontext() and setcontext functions but I have not been able to spot the right file or resource. Any help in this regard will be helpful. I was able to trace to http://fossies.org/dox/glibc-2.14.1/setcontext_8c_source.html but there is no info
[CODE] #include <iostream> #include <string.h> #include <ctype.h> using namespace std; void RemoveSpaces (char *str); void Removevowels (char *str); int main() { system("Color 1A"); char myString[300]; char clear[300]; char cipher[300]; int selection; int x = 0; int i = 0; int opt; cout<<"Enter a string!"<<endl; cin.ignore(); cin.getline(myString,sizeof(myString)); cout<<"Plase select what you …
Is it possible to convert Float or double in a string??? Any idea??
Hi, I want to know what is meant by a code footprint. I tried googling but all of them have explanations that I was really not able to understand. Can anyone please tell me what is means? How is it important and how can it be used(if at all it …
Hi there, I've been learning C lately, and in one of the exercises I've encountered a bit of a frustrating issue. The exercise is to accept a string of characters that are answers to a multiple choice quiz, and then compare them to the correct answers which are in another …
Hi! Im kinda new to c# devt I used to do a php project and Im wondering if theres anyway sql commands in php have comparable commands in c# for example if I wanna read a data in php I use $query = "SELECT * FROM table"; then execute that …
Hey, how do you declare an array of strings using double pointer ? I normally use [CODE]char* str[] = {"this", "works", "fine" ,"for", "me"}; [/CODE] But I want to know if there is a way of declaring array of strings using something like [CODE]char** str; [/CODE] Please show me how …
Hi. Sooner or later I had to go into the depths of C. Today was the day I tried my first things with C. However, I am having a problem although I do not know what actually causes it. The goal of the pogram is to combine the parameters into …
Here's a small snippet from my code. Following a Knuth Shuffle model in the Shuffle function, I get 6 Pointer Expected errors in line 15, but I'm sure its really 2 due to the SWAP function in the header. Now the two things I'm swapping are a random index and …
Hi, I am trying to create a simple program to rename a bunch of files #include <stdio.h> int main(){ int count; for(count = 1; count <= 95; count++){ if(count >= 10){ system("rename \"C:\\wamp\\www\\anime\\kenshin\\Rurouni Kenshin - %d.mkv\" \"%d.mkv\"", count, count); } /* For the episodes that have 0 before the number …
The End.