I have read lots of programmers saying and writing when programming in C/C++ there are lots of issue related to memory. I am planning to learn to program in C/C++. I have beginner knowledge of C/C++ and I want to see some short sample why C/C++ can have issues with memory management. Please Provide some samples.
...
stored_name_t scan_construct_struct(void)
{ stored_name_t stn; int i=0;
scanf("%c %lf %lf",&(stn.name)
,&(stn.(the_lower_limit))
,&(stn.(the_upper_limit)));
for(i=0; (scanf("%s", stn.(numbers[i])))!=0; ++i)
;
return stn;
}
dene.c:37: error:...
I have a table of structures and this structures are 2 dimentional table of constants.
can you teach me on how to get the values in the table of constants.
(note following is just example)
typedef struct
{
unsigned char ** Type1;
unsigned char ** Type2;
} Formula;
typedef struct
{
Formula tformula[size];
} table;...
/*-> struct sam set_of_data[4] -<*/
int main (void)
{
int k = 0;
for(i = 0; i < 4; ++i)
{
char nm;
double thelow, theupp; double numbers[200];
scanf("%c %lf %lf", &nm, &thelow, &theupp);
for (k = 0;
scanf("%lf", &numbers[k]) != 0;
++k) ;
set_of_data[i] = co...
1: /*
2: * File: xyn-playlist.c
3: * Author: Andrei Ciobanu
4: *
5: * Created on June 4, 2010, 12:47 PM
6: */
7:
8: #include <dirent.h>
9: #include <glib.h>
10: #include <stdio.h>
11: #include <stdlib.h>
12: #include <sys/stat.h>
13: #include <unistd.h>
14:
15: /**
16: ...
I just came across that ANSI(ISO) ain't allowing nesting of function..
i want to know what makes gnu c ito implement this functionality(why such need arise).
If a function say(a()) is define with in another function say(b()) then
the lifetime of a() would be whole program?
Will the storage for a() ll be created in a stack allocated to f...
I have the following:
LPSTR email // Has data in it already
LPSTR index=strchr(email,'@');
Now I want to Insert into a new string:
LPSTR username
the part of "email" from the beginning of the string to "index".
For example:
email="[email protected]"
so username="roel" .
Is there a function to do it quick or do I need to build ...
Right now I have a window with horizontal ad vertical scrollbars. I use these parameters to initialize it.
//Set OGL Frame scroll bar
SCROLLINFO inf;
inf.cbSize = sizeof(SCROLLINFO);
inf.fMask = SIF_PAGE | SIF_POS;
inf.nPage = 20;
inf.nPos = 30;
It creates them in the center and I like their size, but when I scroll...
Hello,
I load some data from file:
GInputStream* input_stream;
GFile *file = g_file_new_for_path(file_path);
input_stream = g_file_read(file,generator_cancellable ,NULL);
g_input_stream_read(input_stream, buffer, sizeof (buffer),generator_cancellable,error);
How can i load g_input_stream_read function result to the GdkPixbufLoader o...
in C++ Primer 4th edition 2.1.1, it says "when assigning an out-of-range value to a signed type, it is up to the compiler to decide what value to assign".
I can't understand it. I mean, if you have code like "char 5 = 299", certainly the compiler will generate asm code like "mov BYTE PTR _sc$[ebp], 43"(VC) or "movb $43, -2(%ebp)"(gc...
Here is my situation. I'm creating a drawing application using OpenGL and WinAPI. My OpenGL frame has scrollbars which renders the screen and modifies GlTranslatef when it gets a scroll message. The problem is wen I get too many shapes the scrollbar is less responsive since it cannot rerender it each and every time it gets a scroll messa...
I'm reading characters from the input. Once I find that I've moved to the next row, by checking that the character is a special token, I want the code to put that character back so that it is as if none of the characters on that row have been read.
How do I do that?
This is what I have so far.
char nm; int i=0;
double thelow, the...
Hi,
I am trying to multiply square matrices in parallele with MPI.
I use a MPI_Type_vector to send square submatrixes (arrays of float) to the processes, so they can calculate subproducts. Then, for the next iterations, these submatrices are send to neighbours processes as MPI_Type_contiguous (the whole submatrix is sent). This part is...
I am using the GPC Polygon Clipping lib and want to create a polygon programatically. I only see code for how to create one from a file. How can I do the initialization in my code?
...
I need to write such a define in C/C++
#define scanf( fscanf(inf,
in order to replace each scanf( with fscanf(inf, literary
But I do not know how...
Thanks
...
I want to know how do we proceed to debug a STACKOVERFLOW issue on targets .
I mean what are the steps we should follow to reach a conclusion.
...
scanf("%[^\n]\n",A[i]);
/*that reads input line by line; example:first line is stored in A[0]*/
-> But I want read each element of line and send to struct fuction until
the EOL (end of line)
-> Explaining: In current line,read one data ,then send to struct funcion
to hold,after then ,in for loop, re...
On the heels of a specific problem, a self-answer and comments to it, I'd like to understand if it is a proper solution, workaround/hack or just plain wrong.
Specifically, I rewrote code:
T x = ...;
if (*reinterpret_cast <int*> (&x) == 0)
...
As:
T x = ...;
if (*reinterpret_cast <volatile int*> (&x) == 0)
...
with a volatile q...
Given a series of points, how could I calculate the vector for that line 5 pixels away? Ex:
Given:
\
\
\
How could I find the vector for
\ \
\ \
\ \
The ones on the right.
I'm trying to figure out how programs like Flash can make thick outlines.
Thanks
...
I have this snippet of the code
char *str = “123”;
if(str[0] == 1) printf("Hello\n");
why I can't receive my Hello thanks in advance!
how exactly compiler does this comparison if(str[0] == 1)?
...