I'm almost done with this assignment, and it's killing me. This is my THIRD post about three different sections of this, and I'm honestly embarrassed that I'm struggling this much with the assignment.
The assignment itself is to make a program that performs addition and subtraction of big integers using linked lists (and I'm slowly star...
I am having trouble with my Int2String method. I am new to C so I am not sure if this would be the correct way to go about it. I'm receiving a few error messages:
error: conflicting types for 'int2String'
warning: return makes integer from pointer without a cast
Here is my method:
char int2String(int num, char intStr[10]) {
char ito...
In C, can I say a white space in a string has a NULL type, or something else?
In C, which character represents the termination of a string?
...
Hi all,
I'm just wondering how I would go about splitting a pixel array (R,G,B,A,R,G,B,A,R,G,B,A,etc.) into 64x64 chunks. I've tried several methods myself but they all seem really over-complex and a bit too messy.
I have the following variables (obviously filled with information):
int nWidth, nHeight;
unsigned char *pImage;
And bas...
I have a problem with describing algorithm for finding maximum rectangular area of binary data, where 1 occurs k-times more often than 0. Data is always n^2 bits like this:
For example data for n = 4 looks like:
1 0 1 0
0 0 1 1
0 1 1 1
1 1 0 1
Value of k can be 1 .. j (k = 1 means, that number of 0 and 1 is equal).
For abov...
Hey guys, I had some questions about using inline. I have been told to use it on small functions that I use a lot but I want to understand exactly how it works. Here is just a snippet of how I use it.
static inline point3D createPoint3D(GLfloat x, GLfloat y, GLfloat z){
point3D newPosition;
newPosition.x = x;
newPosition.y = y;...
Hey guys, I had some questions about putting f next to literal values. I know it defines it as a float but do I really need it?
Is this 2.0f * 2.0f any faster then 2.0 * 2.0? and if I have a variable like float a = 2.0;
is this 2.0f * a any faster then 2.0 * a?
...
Reading through the man page of the Linux system call sendfile, I am wondering whether it is possible for the calling program to know when in_fd is at EOF. Presumably, this could be signaled by a return value of 0, but this leads to the question of what a return value of 0 actually means. If sendfile is like write, then a return value of...
So I'm trying to multiply matrices in c. However when I try to multiply the numbers in the two arrays, and put them in an answer array its always zero. heres the code for the method, thanks.
My matrix struct:
typedef struct matrix {
int r;
int c;
double **mat;
} *matrix_t;
My matrix multiplying method:
matrix_t mat_mult(matrix_t...
Hey Guys ! I am a novice coder.. Need your help .. I am currently working on a C Project and could not figure out how to pass command line arguments to my main function in Visual Studio 2010 Express Edition .. I want to debug and also kind of figure out how these command line arguments work.. PLEASE HELP !! Thankyou fellows
...
I am attempting to determine if I can compute the sum of two 32 bit integers without overflow, while making use of only certain bitwise and other operators. So, if the integers x and y can be added without overflow, the following code should return 1, and 0 otherwise.
(((((x >> 31) + (y >> 31)) & 2) >> 1))
However, it returns 0 when ...
How would I only allocate as much memory as really needed without knowing how big the arguments to the function are?
Usually, I would use a fixed size, and calculate the rest with sizeof (note: the code isn't supposed to make sense, but to show the problem):
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
int test(const cha...
Hi, I'm newbie in programming especially c and c++.
I often saw VARNAME_P and VARNAME_T in c/c++.
What are the difference between those two?
Thanks in advance
...
Hi,
I have to retrieve first bit from 1 byte.
For this i stored whole 1 byte in unsigned char Array. Now i retrieved first bit as per below code:
unsigned char byteArray[100];
.....
.....//some code to store 1 byte in byte array
//now 1st bit will be:
int bit=(int) byteArray[0];
I just wanted to confirm that step involved in re...
Help me out, gurus
/*
* In this function, I want the static variable position to point to next element
* of the str, every time I call this function.
*/
void function(char *str){
static char *position = str;
/* Do something here to this position */
position += 1;
}
The purpose of this program is to do string substituti...
I can only make out the similarities, not the differences....
...
I've a program which links to many libraries. g++, by default, prefers to link to shared libraries , even if corresponding archive exists. How can I change this preference to prefer static archive over dynamic libraries , if a static archive exists. Note , I used '-static' option, but it tries to find static archive for all libraries whi...
I want to read some data from the file, the data will have different sizes at different times.
If I use the below code, then:
char dataStr[256];
fread(dataStr, strlen(dataStr), 1, dFd);
fread is returning 0 for the above call and not reading any thing from the file.
But, if I give size as 1 then it successfully reads one char from ...
This is the second time I have got confusing results from the modulo operator, so I am sure I must be missing something about how it works, what am I doing wrong here that is getting me the wrong answers? This function is supposed to take a number and return its digits as a pointer to an array (where the first element says how many digit...
main()
{
char x='202';
printf("%d",x);
}
...