Programming in C.I have two char arrays.char buf1;char buf2;Aren't buf1 and buf2 also pointers?I read in 1024 bytes into buf1 which contain about 300 bytes of characters with newlines. The data is basically a few English sentences. I'm trying to scan buf1 for newlines and then stop at the 1st newline and copy the rest of the data from that 1st newline into buf2.So I run a for loop to look for that new line.
Program in CSay I have a char array of 1024 bytes called buf1.But I only want to print the chars in index 0 up to index 30. I know I could do this with a for loop. But is there any other way? What about maybe storing from 31-1024 to another char array say buf2 with strcpy and somehow popping 31+ out of the buf1 char array?
As you can see we have a problem. If we use a wchar_t instead the string wont be formatted right we need to prefix L in front. If we use char16_t we need to prefix a u in front. Is there a was to make the generic without resorting the the std::string class?
I need to pass a large number of arguments to a function which takes variable number of arguments, such as gtk_list_store_new. But it doesn't look nice if i write something like gtk_list_store_new(NUM,TYPE_A,TYPE_B,TYPE_C,...,TYPE_OMEGA); because of large number of arguments. And, it will be a trouble to change number of columns because of need to manually change arguments to large number of such functions. So, how can i pass all the arguments to a function using a loop? Something like
$1 is an argument which is actually and array. In function we want to assign a value 0 of it's first content. But it's wrong way. Anybody know the right way to assign value in function by passing as argument.
I'm trying to implement a solver for a system of differential equations in Fortran. The solver contains a number of functions which are supposed take real values, 1D arrays of real values or both as arguments and return arrays of real numbers, all of which cause the program to segfault. Example:
function y_exakt(t) implicit none real::t, pi
(the last number in the array seems to change randomly). Then the program crashes either when f(t,y) is called or when dy is returned (after removing the call to f). What could cause these (memory?) problems and/or what could I do to identify the problem? Increasing the maximum stack size with ulimit or compiling the program with -fno-automatic has had no effect. I'm using gfortran (gcc 4.4.3) on a 64-bit Ubuntu Lucid machine. The complete program can be found at [URL].
I am writing a function(in C language in Linux) to initialize an array of a structure from a mysql table by calling a function by reference but I have a problem with call this function by reference . this is my program:PHP Code:
Line 43 points at the snprintf() command.I think the error has to do with the function being virtual and the const after the function definition, however although I have been looking really hard I have not being able to find the reason nor the solution to the problem.
One workaround that I know is moving the block of source withing the virtual function, in the constructor, however having read around (boost library exceptions tutorials) it specifically said that formating of errors messages should not take place withing the construction of objects because we are risking throwing an exceptions and messing up the flow order.
passing a wild card array to cp, I know it can be done but cant figure it out, ive got 3 files all start with the word somefile but have 3 different extensions
somefile.conf somefile.dat somefile.py
there in a folder with a bunch of other files and I just want to copy them to a different location. I remember is being something like cp somefile.[py conf dat] /somewhere but this isn't working Ive searched the net and can't find it with the keywords i'm using.
processArgs $* If I call this script with Code: ./script first second third it'll print each of the argument on a new line - exactly what I would expect. However if I call it with
Code: ./script "Single Argument" "Second-Argument" it splits the first argument in two using the space as a delimitor. The problem appears to be the call to processArgs, where $* doesn't honour the quotes around the variables sent to the script.
I am doing some Linux kernel programming for my research project. I need to record the timestamp (by using cpuid and rdtsc) when an interrupt handler (top half) is first invoked. Due to the time critical nature of the problem itself, I have to do the timestamping inside the interrupt handler itself (the first operation when the handler is called). However, I understand that tasks that are not so time critical should be deferred to a tasklet function (bottom half) for processing because other interrupts are disabled in a (top-half) interrupt handler. I am currently out of idea on how I can pass the timestamp information that I have obtained in the interrupt handler to the corresponding tasklet function.
I'm writing a PHP program. I've encountered a problem; in the following code I try to pass $_POST['delete'] which is an array as the value of a hidden input to some form, but it doesn't do so.there's something wrong with converting PHP array into HTML array. I'm sure that $_POST['delete'] is not null and is a real array.