15,551 Topics

Member Avatar for
Member Avatar for Mayukh_1

I have a small snippet. It is related with several malloc statements. Can somebody please explain. #include <stdio.h> #include <stdlib.h> int main(){ char* ptr1 = (char*)malloc(10); free(ptr1); char* ptr2 = (char*)malloc(10); free(ptr1); char* ptr3 = (char*)malloc(10); free(ptr1); return 0; } **What will happen to the snippet..? Will the malloc for …

Member Avatar for rubberman
0
126
Member Avatar for rizrash

Hey friends i am so excited to join this forum !! its been 3 month since i`ve been learning turbo C !! Now i`ve started lerning and making alot of programs !! Well i am going through one error which is quite funny !! i hope someone of you can …

Member Avatar for David W
0
671
Member Avatar for Queen_1

Hi guys! I have a program that makes you choose what kind of number conversion you would like to do between Binary to Octal and Binary to Hexadecimal . Here's the function that converts binary to hexadecimal: int bintohex(void){ fract=0; bits=0; printf("Enter any binary number: "); while ((ch=getchar()) != EOF …

Member Avatar for David W
0
244
Member Avatar for COKEDUDE

I have this print statement. printf("(n * o ) % m == 0 is invalid so exiting. \n"); And this is the output. (n * o ) Success == 0 is invalid so exiting. I don't even have the word "Success" anywhere in my program. I don't see anything in …

Member Avatar for nullptr
0
108
Member Avatar for COKEDUDE

Can someone please explain these errors? I don't have a multidimensional array so I don't understand how I'm getting this error. main.c:291: warning: passing argument 2 of ‘type_specifier’ from incompatible pointer type main.c:263: note: expected ‘int *’ but argument is of type ‘int **’ main.c:291: warning: passing argument 3 of …

Member Avatar for deceptikon
0
435
Member Avatar for keval_hack

[I]Interesting tricky program using C & C++: [/I] [B]Program 1:[/B] Create a Program which produce output "Hello World" , the program must not contains semicolon ; in other word any statement of the program will not have a termination semicolon. [B]Program 2:[/B] Write a C or C++ program which run …

Member Avatar for Ahamed_1
-1
2K
Member Avatar for COKEDUDE

I am trying to pass the address of strings_line_tokens to split_string. I would think I would need the "&" for the address then one of these methods would work. static void split_string(const char *buffer, size_t buflen, char ***strings_line_tokens) static void split_string(const char *buffer, size_t buflen, char **strings_line_tokens) static void split_string(const …

Member Avatar for deceptikon
0
245
Member Avatar for COKEDUDE

I'm getting infinite recursion here. I'm sorry if this is obvious but I don't see what I'm doing wrong here. program() gets called from main, then program() calls declaration_list(), then declaration_list() calls declaration(). I don't see how in the function declaration_list it ever calls declaration_list() again when right before that …

Member Avatar for overwraith
0
153
Member Avatar for COKEDUDE

Yes I did read these two posts. http://stackoverflow.com/questions/3082914/c-compile-error-variable-sized-object-may-not-be-initialized http://stackoverflow.com/questions/14186879/c-error-variable-sized-object-may-not-be-initialized My case is a bit different because I'm using `char * ptr[buflen]`. This is what I have tried: char *ptr[buflen] = {0}; //This gave me the variable sized object error. char *ptr[buflen]; memset( ptr, 0, buflen*buflen*sizeof(char)); //I figured this would work …

Member Avatar for deceptikon
0
8K
Member Avatar for negru

What books would you recommend for data structures and algorithms in C language? It would be good if recommended books are books of solved problems.

Member Avatar for deceptikon
0
180
Member Avatar for sherwin_2

Create a program that displays the menu and its price. Let the user choose among the menu and compute his total billing. The user can choose an item one at a time and can order one or more quantity of an item he choose. As the user makes an order, …

Member Avatar for rubberman
0
183
Member Avatar for Jakub_3

Hey, guys. I am writing single program, which should replace 10th,11th and 12th character in file with "A" . Problem is, that my program will just write thos A's at the end of the file. Could you,please help me? Thanks in advance. #include <fcntl.h> #include <stdio.h> #include <errno.h> #include <string.h> …

Member Avatar for rproffitt
0
169
Member Avatar for SomeProgrammer

Hello everyone. This is my first post here on Daniweb. Recently I have been working on an AES encryption program using the OpenSSL library. I am running into a small problem, there seems to be a buffer overflow and I cant seem to find the problem area. Or atleast I …

0
125
Member Avatar for Labdabeta

Hi. I am familiar with the following C graphics libraries: Cairo, SDL, SDL2, and OpenGL. The problem I have found with these is that they either require shared libraries (Cairo/SDL/SDL2) or are difficult to make cross-platform (OpenGL). I am wondering if there are any graphics libraries for C that do …

Member Avatar for gusano79
0
2K
Member Avatar for zampi91

Hi everyone, I have registered a rotary encoder in /dev/input/event0 and i try to test it with evtest. This is the output of the test: Input driver version is 1.0.1 Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0 Input device name: "rotary.4" Supported events: Event type 0 …

0
314
Member Avatar for bhagyashri_code
Member Avatar for toxicandy
0
300
Member Avatar for dileepkumar235

Login functionality in C-language : Here the user enters the user id and password. The entered user id and password will be compared with the stored ones and user will be authenticated. While user enters password, characters should not be displayed on the screen. user id comparison must be case …

Member Avatar for Tanmay_1
0
4K
Member Avatar for overwraith

So, I have heard about code porting, basically where you take existing code from one language, and translate it to another language. What I want to know is how does this process work? Are there automated tools for preforming this type of thing, or is it always a manual process? …

Member Avatar for deceptikon
0
244
Member Avatar for Waldis_1

In real life, what is the difference between C# and Visual Basic?. I want to make an application to handle data from a database and I was told that C# is much better, I need advice. Thanks in advanced. Waldis Portes

Member Avatar for overwraith
0
294
Member Avatar for negru

I have a matrix structure (for storing squared matrices) which is defined as typedef struct { int **matrix; int format; }MATRIX; How to add 'n' number of matrices?

Member Avatar for gusano79
0
199
Member Avatar for prgmmgbgnnr

i was given an assignment to create a word construction game where the program will randomly picks a combination of vowels and consonants and the user will build as much words as possible from the choosen letters. my prog will check for the correctness of the words and gives the …

Member Avatar for David W
0
301
Member Avatar for naz1234

is there possible to simplify this statement ? There are same if I using the case statement and while loop. void decode (unsigned char* msg) { if (strstr (msg, "DO=0x00") != NULL) // 0 { //00000 LATGbits.LATG1 = 0 ; //DO1 OFF LATGbits.LATG0 = 1 ; //DO2 OFF LATGbits.LATG13 = …

Member Avatar for 0x69
0
217
Member Avatar for surfingturtle

/* Am not able to understand the operation happening in function showbits(), please help*/ #include <stdio.h> void showbits (unsigned char); int main() { unsigned char num=225,j,k; printf(\nDecimal %d is same as binary", num); showbits (num); for(j=0; j<=4; j++) { k=num<<j; printf (\n%d left shift %d gives", num, j); showbits(k); } …

Member Avatar for surfingturtle
0
195
Member Avatar for JohnMcPherson

Hello, I am having a problem with a C cursor screen that I am developing. The screen compiles without a problem, but when I try to run the screen, it does not come up, and no error message is shown on the screen. Also, there is no file created with …

0
163
Member Avatar for Affan Ahmed

#include <stdio.h> int main(){ int k=0; char q1[0],q2[0],q3[0],q4[0],q5[0],q6[0],q7[0],q8[0],q9[0],q10[0],q11[0]; char a[0]={"b"},b[0]={"a"},c[0]={"d"},d[0]={"c"},e[0]={"d"},f[0]={"c"},g[0]={"b"},h[0]={"d"},i[0]={"c"},j[0]={"a"}; printf(" MCQS TEST PAPER \n \n \n Total ten question each of 1 Marks \n \n \n1.What is your country name? \na)India \n b)Pakistan \nc)Srilanka \nd)America \nEnter your correct option : "); scanf("%s" , &q1); printf("\n \n2. What is your …

Member Avatar for Moschops
0
239
Member Avatar for clife

Hi, I would like to view the source code( the current line it has executed/going to do) in gdb while i am debugging, and i know list and other commands will display the code. what i would like to know is do i need to set some path or something …

Member Avatar for rproffitt
0
316
Member Avatar for kkvk

How to access the below fields of this structure using lib curl write_data pointer variable. typedef struct RESPONSE { char* msg; char* sn; char* gsn; char* veType; char* model; char* deviceKey; char* responseCode; }responsedata , responseptr; I should fill the below values for each member variable of the above structure. …

Member Avatar for gusano79
0
181
Member Avatar for asholpurush1991

A user will enter one line of text at a time . Use EOF or ‘\n’ to determine end of the input. Echo the input one word per line and capitalize each word. Do not use toupper().White spaces, special characters (*, &,+, etc.),and punctuation marks will serve as delimiters .Do …

Member Avatar for gusano79
0
199
Member Avatar for hazelkahn

Basic Arithmetic Game: In this exercise we will program a game to help kids learn integer addition and multiplication. When the program starts the following menu will be presented to the user: Choose the level of difficulty: 1. Easy (numbers will be in the 0 - 10 range) 2. Medium …

Member Avatar for gusano79
-2
224
Member Avatar for hazelkahn

EXERCISE 1 Suppose that nValues and dValues are functions of one argument (the termindex)that return the ni and di of the terms of the continued fraction. Define the function cont-frac such that evaluating cont-frac(k) computes the value of the k-term finite continued fraction. Check your procedures by approximating 1/φ using …

Member Avatar for gusano79
-3
173

The End.