Ahh, brilliant!
Combination of memcpy and remembering the amount of memory initially allocated did the trick.
Thanks everyone!
User Profile
Collapse
-
Copy dynamically allocated array of ints
Example code:
Code:int a, b, c; int *t1; int *t2; t1 = malloc(3*sizeof(int)); t1[0] = 1; t1[1] = 2; t1[2] = 3; t2 = malloc(3*sizeof(int)); t2 = t1; a = t2[0]; b = t2[1]; c = t2[2]; t2[0] = 5;
-
That seems to have done the trick.
Thanks for the solution :)Leave a comment:
-
That doesn't seem to be working unfortumately:
The code I have:
Code:#include <stdio.h> int main(void) { char n[] = "731671765313306249192251196744265747"; //This keeps going for longer in the actual version int v = n[0]; printf("%d \n", v); }
Leave a comment:
-
No worries, I just spend 10 minutes wondering why:
void void(main){
}
wouldn't compile!Leave a comment:
-
-
C - integer from string in array of chars (or array of integers?)
Hi.
I've just thrown myself head first into C, and am having a bit of trouble getting my head round the way the datatypes and arrays work.
At the moment, I'm working on a problem which involves a very long (1000 digit) number - I need to pick out individual digits from it, rather than use it as a whole. The idea I initially had was to do:
char n[] = "12325346547346 34...";
int v = n[0];... -
Managed to sort it - the IsPostBack indeed shouldn't have been there; instead I cleared the tables of their rows and updated them with the new ones.Leave a comment:
-
Please excuse the double post, but I created a very simplified version of the application which has exactly the same effect:
Code:using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public
Leave a comment:
-
C# ASP.net ImageButton click event problems
At current, I have a set of dynamically generated image buttons, which are created with this (excert) of code:
Code:TableCell tasks = new TableCell(); while (reader.Read()) { ImageButton button = new ImageButton(); button.Click += new System.Web.UI.ImageClickEventHandler(taskButton_Click); button.ImageUrl = "Images/task.gif";
No activity results to display
Show More
Leave a comment: