for (int i = 0; i < X; i++)
myitem = (checkedDB) ? dirtyItem : cleanItem;
I wanted to know if there's a way of flipping checkedDB in the same statement, i.e. the next iteration checkedDB is the opposite of it's value, so like XORing.
Consider this function declaration:
int IndexOf(const char *, char);
where char * is a string and char the character to find within the string (returns -1 if the char is not found, otherwise its position). Does it make sense to make the char also const? I always try to use const on pointer parameters but when something is called by value, I normally leave the const away.
What are your thoughts?
Hi
I have a table with the following structure:
id int(11),
name varchar(250)
I have lots of records in the table but when I am trying to find a particluar record which has the following value on the name field:
Lorem ipsum d\'olor sit amet
The query is simply returning a blank recordset. I am not being able to figure out this weird behaviour, when my query is as simple as follows:
SELECT * FROM slot_games WHERE name='Lorem ipsum d\'olor sit amet'
Would appreciate your help please! Thanks in advance.
I want to calculate the quarter Hour from the given two datetimes:
Suppose datetime1 and datetime2 , i am doing somewhat like this :
int d = datetime2.Subtract(datetime1).Hours;
double l = Math.Round(Convert.ToDouble(d/4));
but if the QuarterHour is 3 (ie d=3), whats the good way to show the output- should it be zero or the round one :
3/4 = 0.75. so should i round up to 1 or 0 is ok.
And if round up to 1..how should i?
I'm trying to have method void run( string method ) which would run method in that class. For example:
class Foo {
public:
void run( string method ) {
// this method calls method *method* from this class
}
void bar() {
printf( "Function bar\n" );
}
void foo2() {
printf( "Function foo2\n" );
}
}
Foo foo;
int main( void ) {
foo.run( "bar" );
foo.run( "foo2" );
}
this would print:
Function bar
Function foo2
Thanks! :)
Is there any hack I could use to do this:
template <class TYPE>
class Hello
{
TYPE _var;
};
I would like a way to store
Hello<int> intHello and Hello<char*> charHello
into the same Container such as a Queue / List.
Hi all,
in C++, when you define a function which takes one argument, you have to define the data type of that variable:
void makeProccess(int request)
However, I want to implement a function which takes different data types rather taking statically defined integer type.
void makeProccess(anyType request)
How can I design a proccess like this, any idea?
Thanks.
int i=0; char **mainp;
for(i=0;i<2;++i)
{ mainp[i]=malloc(sizeof(char)*200);
if(!scanf("%[^#],#",mainp[i]))
break;
if(i<2)
scanf("%[^#],#",mainp[i]);
}
why does gcc send me that warnings
warning: implicit declaration of function ‘scanf’
warning: incompatible implicit declaration of built-in function ‘scanf’
warning: ‘mainp’ may be used uninitialized in this function
I am trying to subtract one variable from another, and use that output. but when I subtract them, the outcome is just the second variable negative!
int distance = pointX-pointXTwo;
NSLog(@"%d", distance);
Consider the follwoing fragment:
int a,b;
a = 1;
b = 2;
c = a++++b; // does not work!! Compilation error.
c = a++*+b; // works !!
Please help me understand this behaviour.
Hi, This is a simple question:
I have 2 different view controllers, and each one has its own data stored in its .m file.
I want to take a value, for instance, an integer value (int i=3;) that is declared in ViewController1 and pass it to ViewController2, so I will be able to use that value in the second view controller.
Can anyone please tell me how to do it?
Thanks in advance,
Sagiftw
I have the following entity model
public class Employee
{
public int Employee ID{get;set;}
public string employeename{get;set;}
public datetime employeeDOb{get;set;}
public datetime? employeeDateOfJoin{get;set;}
public string empFamilyname{get;set;}
public datetime empFamilyDob{get;set;}
}
here I have to design a view for collecting employee information and employee family information.
Since I am working on already available data, where in empFamilyDob was not mandatory.
But now it is being made mandatory, the previous data doesn't contain EmpFamilyDob.
So naturally I have added this new property EmpFamilyDob to the Model and made it required through DataAnnotations.
Now there are two set of views to be developed.
1. A view which simply allows to collect the employee information without employee family information. i.e, empFamilyName and EmpFamilyDob.--This view is used by the Hr section to insert empplyee details
Since the empFamilyname and EmpFamilyDob being now made mandatory, some other section will edit the data and update the EmpFamilyName and EmpFamilyDob as and when the information about employee family details are received.
I have action controller for CreateNew and Edit Which is being generated by using the default model.
There are two user actions being performed.
1.When the user clicks the Create new -- he will be able to update only the Employee information
2.As and when the other section receives the employee family details they update the familyname and family date of birth. i.e, EmployeeFamilyname and EmployeFamilyDob.
While creating new record the uses should be able to update employee information only and while editing the information he should be able to update the employeefamily information. Since I have a single view with most of these fields as required and not allowing null , How can I achieve this in a sincle view?
I have recorrected the model like this
public class Employee
{
public int Employee ID{get;set;}
public string employeename{get;set;}
public datetime employeeDOb{get;set;}
public datetime? employeeDateOfJoin{get;set;}
public string empFamilyname{get;set;}
public datetime? empFamilyDob{get;set;}
}
Now by default I hope the createnew action would insert null value for empFamilyname(string datatype) and empFamilyDob . In the Edit action the user should be made to enter empFamilyname and empFamilyDob(mandatory). As there is every chance that the user might edit other information about the employee(like employeeDob) I don't want to go for partial views. Can you help me out with some illustration. Thanks in advance
When would you ever want to scope a String Builder inside a for loop?
Sample Code:
....
for (int i=0; i<cnt; i++) {
....
{
StringBuilder sb = new StringBuilder();
sb.append(",");
....
}
}
....
I have created an array of coordinates. The centre of an image should move through those coordinates. I have used TranslateAnimation to achieve it. But during the animation the image is moving within the last two coordinates.
Below is my code:
private void CreateAnimationAndRun() {
// move to the different coordinates one by one
for(int k=0; k
The above function is called on a button click.
At some places in my code, I print debug messages like this:
int ret = getLinkSpeed(device.getSysName(), linkSpeed);
if (ret < 0)
{
logDebug("Failed to obtain port speed for this device. Error: " + std::string(strerror(errno)));
}
From the documentation it is not entirely clear if strerror will return 0 under certain conditions (which would cause my code to crash). Does anyone know if it's safe?
Hi,
I am trying to only select the objects where the id is smaller than an int value.
e.g.: i have 3 objects - id = 1, id = 2, id = 3
Now I want to only get the objects with the id smaller than the variable i = 2;
How can I manage this?
sql = "SELECT id FROM table_name WHERE id <= i";
Thanks ;-)
Hi there
In a given binding is it possible to specify the path on the source object? Seems like this could a void a lot of trivial converters..
Imagine this..:
class foo
{
bool A
int B
}
<ComboBox ItemsSource="ListOfFoos" SelectedItem="{Binding number, SourcePath=B}" />
I have a wcf restful service with a operation contract that contains two values - an int and a string. This is a post call as well.
If i wrap the call using the BodyStyle = WebMessageBodyStyle.Wrapped. What should i assume the xml request will now look like?