I'm having trouble with some of the pointer/array notation used. I have two lists and am sorting them, and then try to display them. I had 3 comments in my code below as to what the declarations are and why. My code looks like:
int Compare(const void *a, const void *b);
void SortStudents(char *studentList[], size_t studentCount)
{...
I heard fopen supports UTF8 but i dont know how to convert an array of shorts to utf8
How do i create a file with unicode letters in it? I prefer to use only built in libraries (no boost which is not installed on the linux box). I do need to use fopen but its pretty simple to.
...
In the latest Vim:
Is there a way to define a '{' such that it's ignored by the C/C++ compiler (g++) but treated like a '{' in Vim synatx highlighting?
I've tried //{ but it's ignored by Vim too.
...
Just curious, I am reading a book on game AI. And one of the terms that is being used is to normalized a vector. Which is to turn a vector into units. To do so you must divide each dimension x,y and or z by its magnitude. We must we turn a vector into units before we do anything with it. Why ??. and could anyone give a scenario's . Thank...
I'm just starting to learn assembly and I want to round a floating-point value using a specified rounding mode. I've tried to implement this using fstcw, fldcw, and frndint.
Right now i get a couple of errors:
~ $ gc a02p
gcc -Wall -g a02p.c -o a02p
a02p.c: In function `roundD':
a02p.c:33: error: parse error before '[' token
a02p.c:21...
I'm writing a command line program in ANSI C to parse a Quake 2 map file to report how many entities and textures are being used. My development machine is MacBook. I'm testing on OS X Snow Leopard (32-bit), Windows XP (32-bit) and Vista (64-bit), and Ubuntu 9.10 (32-bit).
The code is flawless on the OS X and GCC 4.2. The other pla...
I am trying to learn c++ but most of the tutorials and books I have read or looked up teaches you this...
(I am assuming like most tutorials, they are teaching in the beginning to code either in win32 console or CLR console. In either case the following does not work.)
#include <iostream>
int main( )
{
std::cout << "Hello World\n"...
I am implementing the standard bubble sort algorithm, and I had a question on pointers.
float *SortValues(float *p, size_t n)
{
float temp;
float didSwap;
float *current;
float *last = &p[n - 1];
float *start = p;
do
{
for (didSwap = 0, current = p; current < last; current++) {
if (curre...
I'm doing a hw assignment and my professor uses this code to test our program:
int main()
{
const int SZ1 = 10;
const int SZ2 = 7;
const int SZ3 = 5;
float array1[SZ1];
float array2[SZ2];
float array3[SZ3];
DisplayValues(SortValues(GetValues(array1, SZ1), SZ1), SZ1);
DisplayValues(SortValues(GetValues(array2, SZ...
The question is simple "Say we have an integer 1 <= n <= 12,How to use strftime to display January for '1',February for '2',March for '3' and so on ... ?"
...
Hi,
My application consist of C# code with unmanaged C dll calls.
In my C# code I have an object/class where its properties are both system types such as string and int and other objects I have defined.
I would like to pass this complex (Graph.cs) object to my C (dll) code, what implementation would you suggest here?
I have tried movin...
For pointers, I'm getting confused with declarations and function parameters on when to use char ** or char * or *array[n], etc. Like if a function takes a (*array[n]) parameter, do I pass it a **type?
I try using the Right-Left rule and know that p would be a pointer to a pointer to a char (char **p), and p is an array of n pointers...
I am trying to implement Pollard Rho integer factorization in C/C++.Google gives me a Java implementation of the problem here.
I don't know Java that well,so what I came up with this.My implemenation in C++ works for most cases but not in few like the one "9999", I used there.
I am aware that C++ didn't have Biginteger class so I can't...
Memory access through pointers is said to be more efficient than memory access through an array. I am learning C and the above is stated in K&R. Specifically they say
Any operation that can be achieved by array subscripting can also be done with pointers. The pointer version will in general be faster
I dis-assembled the following ...
ok so if we have a char *hello - ands the string is "hello"
and i do
char *ptr ;
ptr = hello;
then ptr will be pointing at 'h', correct?
Now i have just done an assignmnet in this and completed it using the following terms
if i wanted to move the pointer to the next chatachter i would just do ptr++. If i wanted to use the value of...
My friend said he thinks i may have made a mistake in my programme and wanted to see if i really did. He asked me to send him the binary opposed to the source. As i am new to this i am paranoid that he is doing someting to it? What can you do with the binary that would mean you wouldnt want the source?
thank
...
I'm trying to free up the memory I've allocated with malloc, but the free command doesn't seem to do its job properly according to Eclipse's debugger. How's this possible?
Below is a screenshot of my debugger after it supposedly freed up seCurrent->student->year, which is clearly not the case. year was allocated using malloc.
...
I need to create dll using C. But I saw some problems. OK, first: I need function in dll library to compute angle of the line - tgA = dy/dx. Angle = arctg(dy/dx). And I define this in file framework.c:
JSBool computeAngle(JSContext *cx,
JSObject *obj,
unsigned int argc,
jsva...
Hey all,
I'm translating some MATLAB code into C and the script I'm converting makes heavy use of 3D arrays with 10*100*300 complex entries. The size of the array also depends on the sensor's input, ideally the array should be allocated dynamically. So far I've tried two approaches the first being a flat 1D array along the lines of
va...
Here is the situation : Some process writes lines into a fifo file (created with mkfifo). At some point in my program, I want to read the last line in the fifo, and discard all the others. The procedure may block, only if there is less than one line in the fifo.
I can't come up with a clean way to do this, any ideas ?
EDIT : The writi...