Search Results

Search found 1486 results on 60 pages for 'unsigned'.

Page 14/60 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Types questions in ANSI C

    - by shaharg
    Hi, I having few questions about typed in ANSI C: 1. what's the difference between "\x" in the beginning of a char to 0x in the beginning of char (or in any other case for this matter). AFAIK, they both means that this is hexadecimal.. so what's the difference. when casting char to (unsigned), not (unsigned char) - what does it mean? why (unsigned)'\xFF' != 0xFF? Thanks!

    Read the article

  • C++ operator overloading doubt

    - by avd
    I have a code base, in which for Matrix class, these two definitions are there for () operator: template <class T> T& Matrix<T>::operator() (unsigned row, unsigned col) { ...... } template <class T> T Matrix<T>::operator() (unsigned row, unsigned col) const { ...... } One thing I understand is that the second one does not return the reference but what does const mean in the second declaration. Also which function is called when I do say mat(i,j)

    Read the article

  • win7 + vc7.1 + mfc = stackoverflow

    - by fogbit
    Hello! I've moved my vc7.1 project from WInXP to Win7. After rebuilding i got stackoverflow error in function _malloc_dbg when i start the program. "Unhandled exception at 0x0051bf0f in XXX.exe: 0xC00000FD: Stack overflow." Call stack: msvcr71d.dll!_malloc_dbg(unsigned int nSize=140, int nBlockUse=2, const char * szFileName=0x10267784, int nLine=163) msvcr71d.dll!_calloc_dbg(unsigned int nNum=1, unsigned int nSize=140, int nBlockUse=2, const char * szFileName=0x10267784, int nLine=163) msvcr71d.dll!_mtinit() msvcr71d.dll!_CRTDLL_INIT(void * hDllHandle=0x10200000, unsigned long dwReason=1, void * lpreserved=0x0018fd24) I tried to set up different stacksizes in project options (from 10 to 100 mbytes), in all cases i got this error. How can i fix this?

    Read the article

  • Image processing: smart solution for converting superixel (128x128 pixel) coordinates needed

    - by zhengtonic
    Hi, i am searching for a smart solution for this problem: A cancer ct picture is stored inside a unsigned short array (1-dimensional). I have the location information of the cancer region inside the picture, but the coordinates (x,y) are in superpixel (128x128 unsigned short). My task is to highlight this region. I already solved this one by converting superpixel coordinates into a offset a can use for the unsigned short array. It works fine but i wonder if there is a smarter way to solve this problem, since my solution needs 3 nested for-loops. Is it possible to access the ushort array "superpixelwise", so i can navigate the ushort array in superpixels. ... // i know this does no work ... just to give you an idea what i was thinking of ... typedef struct { unsigned short[128x128] } spix; spix *spixptr; unsigned short * bufptr = img->getBuf(); spixptr = bufptr; ... best regards, zhengtonic

    Read the article

  • Getting plane slices from array data

    - by umanga
    Greetings all, I read 3d grid data (from multiple TIF images) into a structure as follows : typedef struct VolumeData{ int nx; int ny; int nz; unsigned char *data; // size is nx*ny*nz } Now I want to get the plane slices from this 1-D grid data: eg: unsigned char* getXYPlaneStack(VolumeData *vol,int z); I could implement above function because the *data array stores image stack. But i am having difficult time implement along the other axes: unsigned char* getYZPlaneStack(VolumeData *vol,int x); and unsigned char* getXZPlaneStack(VolumeData *vol,int y); any easy algorithm for this? thanks in advance.

    Read the article

  • JNA Passing Structure By Reference Help

    - by tyeh26
    Hi all, I'm trying to use JNA to talk over a USB device plugged into the computer. Using Java and a .dll that was provided to me. I am having trouble with the Write function: C code: typedef struct { unsigned int id; unsigned int timestamp; unsigned char flags; unsigned char len; unsigned char data[16]; } CANMsg; CAN_STATUS canplus_Write( CANHANDLE handle, //long CANMsg *msg ); Java Equivalent: public class CANMsg extends Structure{ public int id = 0; public int timestamp = 0; public byte flags = 0; public byte len = 8; public byte data[] = new byte[16]; } int canplus_Write(NativeLong handle, CANMsg msg); I have confirmed that I can open and close the device. The close requires the NativeLong handle, so i am assuming that the CANMsg msg is the issue here. I have also confirmed that the device works when tested with C only code. I have read the the JNA documentation thoroughly... I think. Any pointers. Thanks all.

    Read the article

  • MySQL counting question

    - by gew
    How do I find out which user entered the most articles and then count how many articles that user entered using PHP & MySQL. Here is my MySQL tables. CREATE TABLE users_articles ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT UNSIGNED NOT NULL, title TEXT NOT NULL, acontent LONGTEXT NOT NULL, PRIMARY KEY (id) ); CREATE TABLE users ( user_id INT UNSIGNED NOT NULL AUTO_INCREMENT, username VARCHAR(255) DEFAULT NULL, pass CHAR(40) NOT NULL, PRIMARY KEY (user_id) );

    Read the article

  • c++ floating point precision loss: 3015/0.00025298219406977296

    - by SigTerm
    The problem. Microsoft Visual C++ 2005 compiler, 32bit windows xp sp3, amd 64 x2 cpu. Code: double a = 3015.0; double b = 0.00025298219406977296; //*((unsigned __int64*)(&a)) == 0x40a78e0000000000 //*((unsigned __int64*)(&b)) == 0x3f30945640000000 double f = a/b;//3015/0.00025298219406977296; the result of calculation (i.e. "f") is 11917835.000000000 (*((unsigned __int64*)(&f)) == 0x4166bb4160000000) although it should be 11917834.814763514 (i.e. *((unsigned __int64*)(&f)) == 0x4166bb415a128aef). I.e. fractional part is lost. Unfortunately, I need fractional part to be correct. Questions: 1) Why does this happen? 2) How can I fix the problem? Additional info: 0) The result is taken directly from "watch" window (it wasn't printed, and I didn't forget to set printing precision). I also provided hex dump of floating point variable, so I'm absolutely sure about calculation result. 1) The disassembly of f = a/b is: fld qword ptr [a] fdiv qword ptr [b] fstp qword ptr [f] 2) f = 3015/0.00025298219406977296; yields correct result (f == 11917834.814763514 , *((unsigned __int64*)(&f)) == 0x4166bb415a128aef ), but it looks like in this case result is simply calculated during compile-time: fld qword ptr [__real@4166bb415a128aef (828EA0h)] fstp qword ptr [f] So, how can I fix this problem? P.S. I've found a temporary workaround (i need only fractional part of division, so I simply use f = fmod(a/b)/b at the moment), but I still would like to know how to fix this problem properly - double precision is supposed to be 16 decimal digits, so such calculation isn't supposed to cause problems.

    Read the article

  • whether rand_r is real thread safe?

    - by terry
    Well, rand_r function is supposed to be a thread safe function. However, by its implementation, I cannot believe it could make itself not change by other threads. Suppose that two threads will invoke rand_r in the same time with the same variable seed. So read-write race will occur. The code rand_r implemented by glibc is listed below. Anybody knows why rand_r is called thread safe? int rand_r (unsigned int *seed) { unsigned int next = *seed; int result; next *= 1103515245; next += 12345; result = (unsigned int) (next / 65536) % 2048; next *= 1103515245; next += 12345; result <<= 10; result ^= (unsigned int) (next / 65536) % 1024; next *= 1103515245; next += 12345; result <<= 10; result ^= (unsigned int) (next / 65536) % 1024; *seed = next; return result; }

    Read the article

  • c/c++ how to convert short to char

    - by changed
    Hi I am using ms c++. I am using struct like struct header { unsigned port : 16; unsigned destport : 16; unsigned not_used : 7; unsigned packet_length : 9; }; struct header HR; here this value of header i need to put in separate char array. i did memcpy(&REQUEST[0], &HR, sizeof(HR)); but value of packet_length is not appearing properly. like if i am assigning HR.packet_length = 31; i am getting -128(at fifth byte) and 15(at sixth byte). if you can help me with this or if their is more elegant way to do this. thanks

    Read the article

  • C++ : integer constant is too large for its type

    - by user38586
    I need to bruteforce a year for an exercise. The compiler keep throwing this error: bruteforceJS12.cpp:8:28: warning: integer constant is too large for its type [enabled by default] My code is: #include <iostream> using namespace std; int main(){ unsigned long long year(0); unsigned long long result(318338237039211050000); unsigned long long pass(1337); while (pass != result) { for (unsigned long long i = 1; i<= year; i++) { pass += year * i * year; } cout << "pass not cracked with year = " << year << endl; ++year; } cout << "pass cracked with year = " << year << endl; } Note that I already tried with unsigned long long result(318338237039211050000ULL); I'm using gcc version 4.8.1 EDIT: Here is the corrected version using InfInt library http://code.google.com/p/infint/ #include <iostream> #include "InfInt.h" using namespace std; int main(){ InfInt year = "113"; InfInt result = "318338237039211050000"; InfInt pass= "1337"; while (pass != result) { for (InfInt i = 1; i<= year; i++) { pass += year * i * year; } cout << "year = " << year << " pass = " << pass << endl; ++year; } cout << "pass cracked with year = " << year << endl; }

    Read the article

  • behavior of memset

    - by Vinicius Horta
    Does this function has the same behavior that 'memset'? (Oops! Your question couldn't be submitted because: Your post does not have much context to explain the code sections; please explain your scenario more clearly. ) inline void SetZeroArray( void *vArray[], unsigned int uArraySize ) { for(unsigned i=0; i<=uArraySize; i++ ) vArray[i] = NULL; } int main( int argc, char *argv[] ) { unsigned int uLevels[500]; SetZeroArray( (void**)uLevels, 500 ); unsigned int ulRLevels[500]; memset( &ulRLevels, 0, sizeof( ulRLevels ) ); system("pause>nul"); return EXIT_SUCCESS; }

    Read the article

  • C++ Vector of vectors is messing with me

    - by xbonez
    If I put this code in a .cpp file and run it, it runs just fine: #include <iostream> #include <vector> #include <string> using namespace std; typedef vector<int> row; typedef vector<row> myMatrix; void main() { //cout << endl << "test" << endl; myMatrix mat(2,2); mat[0][1] = 2; cout << endl << mat[0][1] << endl; } But, if I make a .h and a .cpp file with the .h file like this, it gives me boatloads of errors. #ifndef _grid_ #define _grid_ #include<iostream> #include<vector> #include<string> using namespace std; typedef vector<int> row; typedef vector<row> myMatrix; class grid { public: grid(); ~grid(); int getElement(unsigned int ri, unsigned int ci); bool setElement(unsigned int ri, unsigned int ci, unsigned int value); private: myMatrix sudoku_(9,9); }; #endif These are some of the errors I get: warning C4091: 'typedef ' : ignored on left of 'int' when no variable is declared error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    Read the article

  • SQL CREATE TABLE Error

    - by Adam M-W
    Hi, I've been stuck on this one simple(ish) thing for the last 1/2 hour so I thought I might try to get a quick answer here. What exactly is incorrect about my SQL syntax, assuming I'm using mysql 5.1 CREATE TABLE 'users' ( 'id' MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 'username' VARCHAR(20) NOT NULL, 'password' VARCHAR(40) NOT NULL, 'salt' VARCHAR(40) DEFAULT NULL, 'email' VARCHAR(80) NOT NULL, 'created_on' INT(11) UNSIGNED NOT NULL, 'last_login' INT(11) UNSIGNED DEFAULT NULL, 'active' TINYINT(1) UNSIGNED DEFAULT NULL, ) ENGINE InnoDB; Also, does anyone have any good tutorials about how to use Zend_Auth for complete noobs? Thanks.

    Read the article

  • Complex MySQL table select/join with pre-condition

    - by Howard
    Hello, I have the schema below CREATE TABLE `vocabulary` ( `vid` int(10) unsigned NOT NULL auto_increment, `name` varchar(255), PRIMARY KEY vid (`vid`) ); CREATE TABLE `term` ( `tid` int(10) unsigned NOT NULL auto_increment, `vid` int(10) unsigned NOT NULL default '0', `name` varchar(255), PRIMARY KEY tid (`tid`) ); CREATE TABLE `article` ( `aid` int(10) unsigned NOT NULL auto_increment, `body` text, PRIMARY KEY aid (`aid`) ); CREATE TABLE `article_index` ( `nid` int(10) unsigned NOT NULL default '0', `tid` int(10) unsigned NOT NULL default '0' ) INSERT INTO `vocabulary` values (1, 'vocabulary 1'); INSERT INTO `vocabulary` values (2, 'vocabulary 2'); INSERT INTO `term` values (1, 1, 'term v1 t1'); INSERT INTO `term` values (2, 1, 'term v1 t2 '); INSERT INTO `term` values (3, 2, 'term v2 t3'); INSERT INTO `term` values (4, 2, 'term v2 t4'); INSERT INTO `term` values (5, 2, 'term v2 t5'); INSERT INTO `article` values (1, ""); INSERT INTO `article` values (2, ""); INSERT INTO `article` values (3, ""); INSERT INTO `article` values (4, ""); INSERT INTO `article` values (5, ""); INSERT INTO `article_index` values (1, 1); INSERT INTO `article_index` values (1, 3); INSERT INTO `article_index` values (2, 2); INSERT INTO `article_index` values (3, 1); INSERT INTO `article_index` values (3, 3); INSERT INTO `article_index` values (4, 3); INSERT INTO `article_index` values (5, 3); INSERT INTO `article_index` values (5, 4); Example. Select term of a defiend vocabulary (with non-zero article index), e.g. vid=2 select a.tid, count(*) as article_count from term t JOIN article_index a ON t.tid = a.tid where t.vid = 2 group by t.tid; +-----+---------------+ | tid | article_count | +-----+---------------+ | 3 | 4 | | 4 | 1 | +-----+------------ Question: Select terms a. of a defiend vocabulary (with non-zero article index, e.g. vid=1 = term {1,2}) b. given that those terms are linked with articles which are linked with terms under vid=2, e.g. = {1}, term with tid=2 is excluded since no linkage to terms under vid=2 SQL: Any idea? Expected result: +-----+---------------+ | tid | article_count | +-----+---------------+ | 1 | 2 | +-----+---------------+

    Read the article

  • why no implicit conversion from pointer to reference to const pointer.

    - by user316606
    I'll illustrate my question with code: #include <iostream> void PrintInt(const unsigned char*& ptr) { int data = 0; ::memcpy(&data, ptr, sizeof(data)); // advance the pointer reference. ptr += sizeof(data); std::cout << std::hex << data << " " << std::endl; } int main(int, char**) { unsigned char buffer[] = { 0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22, }; /* const */ unsigned char* ptr = buffer; PrintInt(ptr); // error C2664: ... PrintInt(ptr); // error C2664: ... return 0; } When I run this code (in VS2008) I get this: error C2664: 'PrintInt' : cannot convert parameter 1 from 'unsigned char *' to 'const unsigned char *&'. If I uncomment the "const" comment it works fine. However shouldn't pointer implicitly convert into const pointer and then reference be taken? Am I wrong in expecting this to work? Thanks!

    Read the article

  • What's the error in my MySQL statement?

    - by Jim
    The following SQL statement has a syntax error according to phpMyAdmin, but I can't spot what it is. Any ideas? CREATE TABLE allocations( `student_uid` INT unsigned NOT NULL DEFAULT 0, `active` INT unsigned NOT NULL DEFAULT 1, `name` VARCHAR( 255 ) NOT NULL DEFAULT '', `internal_id` VARCHAR( 255 ) DEFAULT '', `tutor_uid` INT NOT NULL DEFAULT 0, `allocater_uid` INT unsigned NOT NULL DEFAULT 0, `time_created` INT NOT NULL DEFAULT 0, `remote_time` FLOAT NOT NULL DEFAULT 0, `next_lesson` VARCHAR NOT NULL DEFAULT -1, PRIMARY KEY ( student_uid ) );

    Read the article

  • C++ Vector of vectors

    - by xbonez
    I have a class header file called Grid.h that contains the following 2 private data object: vector<int> column; vector<vector<int>> row; And a public method whose prototype in Grid.h is such: int getElement (unsigned int& col, unsigned int& row); The definition of above mentioned function is defined as such in Grid.cpp: int getElement (unsigned int& col, unsigned int& row) { return row[row][col] ; } When I run the program, I get this error: error C2109: subscript requires array or pointer type Whats going wrong?

    Read the article

  • MySQL Multiple Table Join

    - by hitman001
    I have a 3 tables that I'm trying to join and get distinct results. CREATE TABLE `car` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ) ENGINE=InnoDB mysql> select * from car; +----+-------+ | id | name | +----+-------+ | 1 | acura | +----+-------+ CREATE TABLE `tires` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `tire_desc` varchar(255) DEFAULT NULL, `car_id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `new_fk_constraint` (`car_id`), CONSTRAINT `new_fk_constraint` FOREIGN KEY (`car_id`) REFERENCES `car` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB mysql> select * from tires; +----+-------------+--------+ | id | tire_desc | car_id | +----+-------------+--------+ | 1 | front_right | 1 | | 2 | front_left | 1 | +----+-------------+--------+ CREATE TABLE `lights` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `lights_desc` varchar(255) NOT NULL, `car_id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `new1_fk_constraint` (`car_id`), CONSTRAINT `new1_fk_constraint` FOREIGN KEY (`car_id`) REFERENCES `car` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB mysql> select * from lights; +----+-------------+--------+ | id | lights_desc | car_id | +----+-------------+--------+ | 1 | right_light | 1 | | 2 | left_light | 1 | +----+-------------+--------+ Here is my query. mysql> SELECT name, group_concat(tire_desc), group_concat(lights_desc) FROM car left join tires on car.id = tires.car_id left join lights on car.id = car_id group by car.id; +-------+-----------------------------------------------+-----------------------------------------------+ | name | group_concat(tire_desc) | group_concat(lights_desc) | +-------+-----------------------------------------------+-----------------------------------------------+ | acura | front_right,front_right,front_left,front_left | right_light,left_light,right_light,left_light | +-------+-----------------------------------------------+-----------------------------------------------+ I get duplicate entires and this is what I would like to get. +-------+-----------------------------------------------+--------------------------------+ | name | group_concat(tire_desc) | group_concat(lights_desc) | +-------+-----------------------------------------------+--------------------------------+ | acura | front_right,front_left | right_light,left_light | +-------+-----------------------------------------------+--------------------------------+ I cannot use distinct in group_concat because I might have legitimate duplicates which I would like to keep. Is there any way to do this query using joins and not using inner selects like the statement below? SELECT name, (select group_concat(tire_desc) from tires where car.id = tires.car_id), (select group_concat(lights_desc) from lights where car.id = lights.car_id) FROM car Also, if I will use inner selects, will there be any performance issues over joins?

    Read the article

  • Shall I optimize or let compiler to do that?

    - by Knowing me knowing you
    What is the preferred method of writing loops according to efficiency: Way a) /*here I'm hoping that compiler will optimize this code and won't be calling size every time it iterates through this loop*/ for (unsigned i = firstString.size(); i < anotherString.size(), ++i) { //do something } or maybe should I do it this way: Way b) unsigned first = firstString.size(); unsigned second = anotherString.size(); and now I can write: for (unsigned i = first; i < second, ++i) { //do something } the second way seems to me like worse option for two reasons: scope polluting and verbosity but it has the advantage of being sure that size() will be invoked once for each object. Looking forward to your answers.

    Read the article

  • Correct way to initialize dynamic Array in C++

    - by mef
    Hey guys, I'm currently working on a C++ project, where dynamic arrays often appear. I was wondering, what could be the correct way to initialize a dynamic array using the new-operator? A colleague of mine told me that it's a no-no to use new within the constructor, since a constructor is a construct that shouldn't be prone to errors or shouldn't fail at all, respectively. Now let's consider the following example: We have two classes, a more or less complex class State and a class StateContainer, which should be self-explained. class State { private: unsigned smth; public: State(); State( unsigned s ); }; class StateContainer { private: unsigned long nStates; State *states; public: StateContainer(); StateContainer( unsigned long n ); virtual ~StateContainer(); }; StateContainer::StateContainer() { nStates = SOME_DEFINE_N_STATES; states = new State[nStates]; if ( !states ) { // Error handling } } StateContainer::StateContainer( unsigned long n ) { nStates = n; try { states = new State[nStates] } catch ( std::bad_alloc &e ) { // Error handling } } StateContainer::~StateContainer() { if ( states ) { delete[] states; states = 0; } } Now actually, I have two questions: 1.) Is it ok, to call new within a constructor, or is it better to create an extra init()-Method for the State-Array and why? 2.) Whats the best way to check if new succeeded: if (!ptr) std::cerr << "new failed." or try { /*new*/ } catch (std::bad_alloc) { /*handling*/ } 3.) Ok its three questions ;o) Under the hood, new does some sort of ptr = (Struct *)malloc(N*sizeof(Struct)); And then call the constructor, right?

    Read the article

  • What's wrong with this inner query (MySQL)...

    - by stuboo
    ...besides the fact that I am a total amateur? My table is set up like this: CREATE TABLE `messages` ( `id` int(6) unsigned NOT NULL AUTO_INCREMENT, `patient_id` int(6) unsigned NOT NULL, `message` varchar(255) NOT NULL, `savedate` int(10) unsigned NOT NULL, `senddate` int(10) unsigned NOT NULL, `SmsSid` varchar(40) NOT NULL COMMENT 'where we store the cookies from twilio', `sendorder` tinyint(3) unsigned NOT NULL COMMENT 'the order we want the msg sent in', `sent` tinyint(1) NOT NULL COMMENT '0=queued, 1=sent, 2=sent-unqueued,4=rec-unread,5=recd-read', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=143 ; I need a query that will SELECT * FROM `messages` WHERE `senddate` < $now AND `sent` = 0 (AND LIMIT TO ONLY ONE RECORD PER `patient_id`) I've tried the following: SELECT * FROM `messages` WHERE `senddate` IN (SELECT `patient_id`, max(`senddate`) GROUP by `patient_id`) AND `senddate` < $now AND `sent` = 0 ; But I get this error: MySQL client version: 5.1.37 `#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP by patient_id) AND senddate < 1270093898 AND sent = 0 LIMIT 0, 30' at line 5

    Read the article

  • C socket and openssl (RSA)

    - by giozh
    there's something strange in my client/server socket using RSA. If i test it on localhost, everithing goes fine, but if i put client on a pc and server on othe pc, something gone wrong. Client after call connect, call a method for public keys exchange with server. This part of code works fine. After this, client send a request to server: strcpy(send_pack->op, "help\n"); RSA_public_encrypt(strlen(send_pack->op), send_pack->op, encrypted_send->op, rsa_server, padding); rw_value = write(server, encrypted_send, sizeof (encrypted_pack)); if (rw_value == -1) { stampa_errore(write_error); close(server); exit(1); } if (rw_value == 0) { stampa_errore(no_response); close(server); exit(1); } printf("---Help send, waiting for response\n"); set_alarm(); rw_value = read(server, encrypted_receive, sizeof (encrypted_pack)); alarm(0); if (rw_value == -1) { stampa_errore(read_error); exit(1); } if (rw_value == 0) { stampa_errore(no_response); close(server); exit(1); } RSA_private_decrypt(RSA_size(rsa), encrypted_receive->message, receive_pack->message, rsa, padding); printf("%s\n", receive_pack->message); return; } but when server try to decrypt the receive message on server side, the "help" string doesn't appear. This happen only on the net, on localhost the same code works fine... EDIT: typedef struct pack1 { unsigned char user[encrypted_size]; unsigned char password[encrypted_size]; unsigned char op[encrypted_size]; unsigned char obj[encrypted_size]; unsigned char message[encrypted_size]; int id; }encrypted_pack; encrypted_size is 512, and padding used is RSA_PKCS1_PADDING

    Read the article

  • Need help with a SQL Query

    - by Jack
    I have created a table with the following structure- $sql = "CREATE TABLE followers ( uid int UNSIGNED NOT NULL UNIQUE, PRIMARY KEY(uid), follower_count int UNSIGNED , is_my_friend bool, status_count int UNSIGNED, location varchar(50) )"; I need to find the uid of the person with max(status_count+follower_count) and whose is_my_friend = 1 I wrote the following query but I ain't getting the correct uid. SELECT p.uid FROM (select uid,is_my_friend,max(follower_count+status_count) from followers) p WHERE p.is_my_friend = 1;

    Read the article

  • C++ FBX Animation Importer Using the FBX SDK

    - by Mike Sawayda
    Does anyone have any experience using the FBX SDK to load in animations. I got the meshes loaded in correctly with all of their verts, indices, UV's, and normals. I am just now trying to get the Animations working correctly. I have looked at the FBX SDK documentation with little help. If someone could just help me get started or point me in the right direction I would greatly appreciate it. I added some code so you can kinda get an idea of what I am doing. I should be able to place that code anywhere in the load FBX function and have it work. //GETTING ANIMAION DATA for(int i = 0; i < scene->GetSrcObjectCount<FbxAnimStack>(); ++i) { FbxAnimStack* lAnimStack = scene->GetSrcObject<FbxAnimStack>(i); FbxString stackName = "Animation Stack Name: "; stackName += lAnimStack->GetName(); string sStackName = stackName; int numLayers = lAnimStack->GetMemberCount<FbxAnimLayer>(); for(int j = 0; j < numLayers; ++j) { FbxAnimLayer* lAnimLayer = lAnimStack->GetMember<FbxAnimLayer>(j); FbxString layerName = "Animation Stack Name: "; layerName += lAnimLayer->GetName(); string sLayerName = layerName; queue<FbxNode*> nodes; FbxNode* tempNode = scene->GetRootNode(); while(tempNode != NULL) { FbxAnimCurve* lAnimCurve = tempNode->LclTranslation.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_X); if(lAnimCurve != NULL) { //I know something needs to be done here but I dont know what. } for(int i = 0; i < tempNode->GetChildCount(false); ++i) { nodes.push(tempNode->GetChild(i)); } if(nodes.size() > 0) { tempNode = nodes.front(); nodes.pop(); } else { tempNode = NULL; } } } } Here is the full function bool FBXLoader::LoadFBX(ParentMeshObject* _parentMesh, char* _filePath, bool _hasTexture) { FbxManager* fbxManager = FbxManager::Create(); if(!fbxManager) { printf( "ERROR %s : %d failed creating FBX Manager!\n", __FILE__, __LINE__ ); } FbxIOSettings* ioSettings = FbxIOSettings::Create(fbxManager, IOSROOT); fbxManager->SetIOSettings(ioSettings); FbxString filePath = FbxGetApplicationDirectory(); fbxManager->LoadPluginsDirectory(filePath.Buffer()); FbxScene* scene = FbxScene::Create(fbxManager, ""); int fileMinor, fileRevision; int sdkMajor, sdkMinor, sdkRevision; int fileFormat; FbxManager::GetFileFormatVersion(sdkMajor, sdkMinor, sdkRevision); FbxImporter* importer = FbxImporter::Create(fbxManager, ""); if(!fbxManager->GetIOPluginRegistry()->DetectReaderFileFormat(_filePath, fileFormat)) { //Unrecognizable file format. Try to fall back on FbxImorter::eFBX_BINARY fileFormat = fbxManager->GetIOPluginRegistry()->FindReaderIDByDescription("FBX binary (*.fbx)"); } bool importStatus = importer->Initialize(_filePath, fileFormat, fbxManager->GetIOSettings()); importer->GetFileVersion(fileMinor, fileMinor, fileRevision); if(!importStatus) { printf( "ERROR %s : %d FbxImporter Initialize failed!\n", __FILE__, __LINE__ ); return false; } importStatus = importer->Import(scene); if(!importStatus) { printf( "ERROR %s : %d FbxImporter failed to import the file to the scene!\n", __FILE__, __LINE__ ); return false; } FbxAxisSystem sceneAxisSystem = scene->GetGlobalSettings().GetAxisSystem(); FbxAxisSystem axisSystem( FbxAxisSystem::eYAxis, FbxAxisSystem::eParityOdd, FbxAxisSystem::eLeftHanded ); if(sceneAxisSystem != axisSystem) { axisSystem.ConvertScene(scene); } TriangulateRecursive(scene->GetRootNode()); FbxArray<FbxMesh*> meshes; FillMeshArray(scene, meshes); unsigned short vertexCount = 0; unsigned short triangleCount = 0; unsigned short faceCount = 0; unsigned short materialCount = 0; int numberOfVertices = 0; for(int i = 0; i < meshes.GetCount(); ++i) { numberOfVertices += meshes[i]->GetPolygonVertexCount(); } Face face; vector<Face> faces; int indicesCount = 0; int ptrMove = 0; float wValue = 0.0f; if(!_hasTexture) { wValue = 1.0f; } for(int i = 0; i < meshes.GetCount(); ++i) { int vertexCount = 0; vertexCount = meshes[i]->GetControlPointsCount(); if(vertexCount == 0) continue; VertexType* vertices; vertices = new VertexType[vertexCount]; int triangleCount = meshes[i]->GetPolygonVertexCount() / 3; indicesCount = meshes[i]->GetPolygonVertexCount(); FbxVector4* fbxVerts = new FbxVector4[vertexCount]; int arrayIndex = 0; memcpy(fbxVerts, meshes[i]->GetControlPoints(), vertexCount * sizeof(FbxVector4)); for(int j = 0; j < triangleCount; ++j) { int index = 0; FbxVector4 fbxNorm(0, 0, 0, 0); FbxVector2 fbxUV(0, 0); bool texCoordFound = false; face.indices[0] = index = meshes[i]->GetPolygonVertex(j, 0); vertices[index].position.x = (float)fbxVerts[index][0]; vertices[index].position.y = (float)fbxVerts[index][1]; vertices[index].position.z = (float)fbxVerts[index][2]; vertices[index].position.w = wValue; meshes[i]->GetPolygonVertexNormal(j, 0, fbxNorm); vertices[index].normal.x = (float)fbxNorm[0]; vertices[index].normal.y = (float)fbxNorm[1]; vertices[index].normal.z = (float)fbxNorm[2]; texCoordFound = meshes[i]->GetPolygonVertexUV(j, 0, "map1", fbxUV); vertices[index].texture.x = (float)fbxUV[0]; vertices[index].texture.y = (float)fbxUV[1]; face.indices[1] = index = meshes[i]->GetPolygonVertex(j, 1); vertices[index].position.x = (float)fbxVerts[index][0]; vertices[index].position.y = (float)fbxVerts[index][1]; vertices[index].position.z = (float)fbxVerts[index][2]; vertices[index].position.w = wValue; meshes[i]->GetPolygonVertexNormal(j, 1, fbxNorm); vertices[index].normal.x = (float)fbxNorm[0]; vertices[index].normal.y = (float)fbxNorm[1]; vertices[index].normal.z = (float)fbxNorm[2]; texCoordFound = meshes[i]->GetPolygonVertexUV(j, 1, "map1", fbxUV); vertices[index].texture.x = (float)fbxUV[0]; vertices[index].texture.y = (float)fbxUV[1]; face.indices[2] = index = meshes[i]->GetPolygonVertex(j, 2); vertices[index].position.x = (float)fbxVerts[index][0]; vertices[index].position.y = (float)fbxVerts[index][1]; vertices[index].position.z = (float)fbxVerts[index][2]; vertices[index].position.w = wValue; meshes[i]->GetPolygonVertexNormal(j, 2, fbxNorm); vertices[index].normal.x = (float)fbxNorm[0]; vertices[index].normal.y = (float)fbxNorm[1]; vertices[index].normal.z = (float)fbxNorm[2]; texCoordFound = meshes[i]->GetPolygonVertexUV(j, 2, "map1", fbxUV); vertices[index].texture.x = (float)fbxUV[0]; vertices[index].texture.y = (float)fbxUV[1]; faces.push_back(face); } meshes[i]->Destroy(); meshes[i] = NULL; int indexCount = faces.size() * 3; unsigned long* indices = new unsigned long[faces.size() * 3]; int indicie = 0; for(unsigned int i = 0; i < faces.size(); ++i) { indices[indicie++] = faces[i].indices[0]; indices[indicie++] = faces[i].indices[1]; indices[indicie++] = faces[i].indices[2]; } faces.clear(); _parentMesh->AddChild(vertices, indices, vertexCount, indexCount); } return true; }

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >