I have simple task concerning 'new' operator. I need to create array of 10 chars and then input those chars using 'cin'. Should it look like this ? :
char c = new char[10];
for(int i=0; i < 10; i++)
{
cin >> char[i] >> endl;
}
I'm writing code in C++, but I really like K/APL's array-oriented style.
Does anyone know of a good set of operator overloading tricks / macros / ... to allow some K/APL -style programming in C++?
Thanks!
Hi everyone,
I want to parse a text file, where
I get numbers that are between parenthesis like
this:
1 2 3 (4 - 7) 8 9
1 3 8 (7 - 8) 2 1
1 2 (8 - 10) 3 2
should return an array for each:
array1:
4
7
8
array2:
7
8
10
I am thinking of using split for each line, like line.split("("), but that doesn't quite doing the trick.. I was wondering if there is something more sophisticated for the job.
Any help appreciated,
Ted
I've found plenty of tutorials / questions on Stackoverflow that deal with copying char arrays from C/JNI side into something like a byte[] in Java, but not the other way around.
I am using a native C library which expects a byte array. I simply want to get data from a byte[] in java, into preferably an unsigned char[] in C.
Long story short: What is the best way of copying data from a jBytearray in JNI? Is there any way to detect it's size?
Hi,
I am looking for ways to implement custom user-roles in windows application with vb.net. I got a database table called Roles with Administrator and User entries. User cannot see some of the form data. In ASP.NET MVC we can do like.
[Authorize(Roles = "Administrator")]
public function GetAccount() as Array
End Function
If it could be done this way that would be great.
Thanks in advance.
I have got a program having an array of buttons, each of these button has their mouselistener event.
Now, how can i find which of the buton is clicked through the mouse listener.
I have a friend who wrote code for a large array with 1,048,576 maximum elements. Everything runs fine when complied using ./make but but when using just ./ we get a segmentation fault. It's obviously not too crucial of a prob to solve. Nonetheless, I am very curious about it. if anyone has seen this or has any Ideas as why...
Have a question about Android "android.graphics.Path", I know how to create a Path from a set points as float[], but could not find anyway to get back the array from the Path object. Is it possible? Thanks in advance.
When dealing with cell arrays, I can use the deal() function to assign cells to output variables, such as:
[a, b, c] = deal(myCell{:});
or just:
[a, b, c] = myCell{:};
I would like to do the same thing for a simple array, such as:
myArray = [1, 2, 3];
[a, b, c] = deal(myArray(:));
But this doesn't work. What's the alternative?
I have an embedded form with a choice widget. I'm trying to pass a default value from the main form to the widget. I'm trying to pass the value to the form as an option, then once I have it in the embedded form do I just do something like:
new sfwidgetformchoice(array(...,'default' => $this->getOption('default'))
doesn't seem to work
I want to take a string from stdin but I don't want a static array of fixed size
I know that scanf need something where save the stdin input, but I can't do something like this:
char string[10]
scanf("%s",string);
becouse I need to know before how long will be the string in order to allocate the right memory space.
Can you help me to resolve this problem?
Wikipedia's definition for Iterator pattern design: the Iterator pattern is a design pattern in which iterators are used to access the elements of an aggregate object sequentially without exposing its underlying implementation.
Iterator interface in java provides the following methods
hasNext()
next()
remove()
Is there a pattern design, or a java interface for inserting / deleting elements, and getting length of the aggregate object, in addition to iterating them? I know remove() is an optional method that can be used once per call to next(), but I am implementing a circular FIFO array and need a method delete() independent of iterator's next().
I have an in-line date picker in which I want to highlight some dates based on array of strings from the server side.
I found out the on load of the page with the datepicker, events the matches in the current month will not be highlighted. when I click the next month button the events on the next moth will be highlighted.
What I discovered that i the matching only get highlighted when I click to the next month and not when I click back to the previous month.
Below is my script:
var actionCalDates = new Array();
function getDates(month, year) {
$.ajax({
url: "/Index/GetAllAlerts",
data: {
month: month,
year: year
},
success: function (result) {
var date = new Date();
var i = new Number(date.getMonth());
i += 1;
actionCalDates = result.split(",");
}
});
}
function getTitle(ar, d) {
var result = "";
for (var i = 0; i < ar.length; i++) {
if (ar[i].indexOf(d) != -1) {
var e = actionCalDates[i].split(";");
result += e[0] + "\n";
}
}
return result;
}
$('#calendar').datepicker({
numberOfMonths: [1, 1],
showCurrentAtPos: 0,
dateFormat: 'dd/mm/y',
beforeShowDay: function (thedate) {
var theday = thedate.getDate();
var x = new Number(thedate.getMonth());
x += 1;
var date = thedate.getDate() + "/" + x + "/" + thedate.getFullYear();
getDates(x, thedate.getFullYear());
for (var i = 0; i < actionCalDates.length; i++) {
var entry = actionCalDates[i].split(";");
if (date == entry[1]) {
return [true, "highlight", getTitle(actionCalDates, date)];
}
}
return [true, "", ""];
},
onChangeMonthYear: function (year, month, inst) {
getDates(month, year);
},
onSelect: function (d, instance) {
$.ajax({
url: '/Index/AlertConvertDate',
datatype: 'text',
data: { dateString: d },
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.statusText);
alert(thrownError);
},
success: function (data) {
window.SetHomeContent(data);
}
});
}
});
Please can someone point out where I went wrong?
Thank you all.
I have a problem about multiple function processing , listed as below code,
the main function is btnEvalClick, I have try to use alter native 1and 2 to wait the function not move to next record before theprocessed function finish, but it does not work
//private function btnEvalClick(event:Event):void {
// var i:int;
// for(i= 0; i < (dataArr1.length); i++) {
// dispatchEvent( new FlexEvent('test') );
// callfunc1('cydatGMX'); //call function 1
// callfun2('cydatGMO'); //call function 1
// editSave(); //save record (HTTP)
//## Alternative 1
//if (String(event) == 'SAVEOK') {
// RecMov('next'); //move record if save = OK
//}
//## Alternative 2
//while (waitfc == '') // if waitfc not 'OK' continue looping
//{
// z = z + 1;
//}
// RecMov('next'); //Move to next record to process
//}
//private function callfunc1(tasal:String):void {
// var mySO :SharedObject;
// var myDP: Array;
// var i:int;
// var prm:Array;
// try
// {
// mySO = SharedObject.getLocal(tasal,'/');
// prm = mySO.data.txt.split('?');
// for(i=0; i < (prm.length - 1); i++) {
// myDP = prm[i].toString().split('^');
// if ( myDP[0].toString() == String(dataArr1[dg].MatrixCDCol)){
// myDPX = myDP;
// break;
// }
// }
// }
// catch (err:Error) {
// Alert.show('Limit object creation fail (' + tasal + '), please retry );
// }
//}
//private function editSave():void
//{
// var parameters:* =
// {
// 'CertID': CertIDCol.text, 'AssetID': AssetIDCol.text, 'CertDate': cdt, //'Ccatat': CcatatCol.text, 'CertBy': CertByCol.text, 'StatusID': StatusIDCol.text, //'UpdDate': lele, 'UpdUsr': ApplicationState.instance.luNm };
// doRequest('Update', parameters, saveItemHandler);
//}
//private function doRequest(method_name:String, parameters:Object, callback:Function):void
// {
// add the method to the parameters list
// parameters['method'] = (method_name + 'ASC');
// gateway.request = parameters;
// var call:AsyncToken = gateway.send();
// call.request_params = gateway.request;
// call.handler = callback;
// }
//private function saveItemHandler(e:Object):void
// {
// if (e.isError)
// {
// Alert.show('Error: ' + e.data.error);
// }
// else
// {
// Alert.show('Record Saved..');
// waitfc = 'OK';
// dispatchEvent( new FlexEvent('SAVEOK') );
// }
// }
Hi I know about several PDF Generators for php (fpdf, dompdf, etc.)
What I want to know is about a parser.
For reasons beyond my control, certain information I need is only in a table inside a pdf
and I need to extract that table and convert it to an array.
Any suggestions?
I'm still very new to codeigniter. The issue i'm having is that the file uploads fine and it writes to the database without issue but it just doesn't return me to the upload form. Instead it stays in the do_upload and doesn't display anything. Even more bizarrely there is some source code behind the scenes. Can someone tell my what it is i'm doing wrong because I want to be returning to my upload form after submission. Thanks in advance. Below is my code:
Controller:
function do_upload()
{
if($this->Upload_model->do_upload())
{
$this->load->view('home/upload_form');
}else{
$this->load->view('home/upload_success', $error);
}
}
Model:
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '2000';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
return $error;
}
else
{
$data = $this->upload->data();
$full_path = 'uploads/' . $data['file_name'];
$spam = array(
'image_url' => $full_path,
'url' => $this->input->post('url')
);
$id = $this->input->post('id');
$this->db->where('id', $id);
$this->db->update('NavItemData', $spam);
return true;
}
}
View (called upload_form):
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<?php if(isset($buttons)) : foreach($buttons as $row) : ?>
<h2><?php echo $row->image_url; ?></h2>
<p><?php echo $row->url; ?></p>
<p><?php echo $row->name; ?></p>
<p><?php echo anchor("upload/update_nav/$row->id", 'edit'); ?></p>
<?php endforeach; ?>
<?php endif; ?>
</body>
</html>
var vals = new Array();
var i=0;
var options='';
jQuery('#SearchResultsTable123 tr:gt(0) td:nth-child(2)').each(function(){
var t=jQuery(this).html();
if(jQuery.inArray(t, vals) < 0)
{
vals[i]=t;
i++;
}
});
for(var j=0;j
this code gives me the distinct value of that colomn but only for visible page.
I need to dynamically create textbox.
This is my code, but with this I create only one textbox:
Public Sub CreateTextBox()
Dim I As Integer
Dim niz As Array
For I = 1 To 5
Dim myTextBox = New TextBox
myTextBox.Text = "Control Number:" & I
Me.Controls.Add(myTextBox)
Next
End Sub
So how i can dynamically create textbox?
Thanks!
I have an array of checkboxes in a complex dynamic-html form. Whenever a user clicks one checkbox, a fairly expensive query is generated and submitted to a remote server.
I want to delay this submit action depending on the users next action. If the user clicks several checkboxes quickly, all of the first clicks should be discarded, only the last one is processed and eventually submitted after 1 second or so.
maybe this is a common problem but I have never worked with timeouts before.
Given a array of random integers, sort the odd elements in descending order and even numbers in ascending order.
e.g. for input (1,4,5,2,3,6,7)
Output = (7,5,3,1,2,4,6)
Optimize for time complexity.
I am trying the to query my Status Update repository using the following
var result = (from s in _dataContext.StatusUpdates
where s.Username == "friend1" && s.Username == "friend2" etc...
select s).ToList();
Insead of using s.Username == "friendN" continously is there anyway I can pass a list or array or something like that rather that specifying each one, or can i use a foreach loop in the middle of the query.
Thanks
I have created 5 NSDictionary's. I stored them in NSArray. I need to get the values stored in NSDictionaries. How can do it ?
I tried calling [[array objectAtIndex:i]objectForKey:key1].
But, it is crashing by giving the message:unrecognized selector sent to instance
How to get the data ?