Tuesday 15 September 2015

In C, char array and string array in c shows different size, but when compared they are same -


In the attempt of four arrays in C, I came up with this problem.

  void main () {four buffers [5] = {'s', 'd', 'f', 'd', 'f'}; Four [5] = "SDFDF"; Printf ("% d \ n", * A == * buffer); Printf ("% s \ n", buffer); Printf ("% d \ n", (int) string (buffer)); Printf ("% d \ n", (int) string (a)); }  

is output

  1 sdfdf sdfdf 5 6  

The main problem is that '\ 0' , correctly defines 5 character string and To get started with the initial list, it should be

  four buffer [6] = {'s', 'd', 'f', such as  char  From an array, 'D', 'F', '\ 0'};   

The second version in your code is incorrect because the array can only store 5 characters, again

  char a [6] = "SDFDF"; Instead of 5 * /  

/ * ^ 6 you can not expect any work after that part of the code to work, when you have lost '\ 0 '.

printf () with "% s" spcifier and strlen () expect previous special value '\ 0' or 0 if you want, to stay there, when it is not, then these functions apply undefined behavior because they go beyond the end of the array There are '\ 0' . Searching for


html - PHP <ul> <li> database -


I get a & lt; I am tring to put a picture, title and rating of each film within the array in ul & gt; & Lt; Li & gt; But I can only put it in the first film, title and rating.

  & lt ;! DOCTYPE html public "- // W3C // DTD XHTML 1.0 strict // n" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> & Lt ;? Php require_once 'init.php'; Need_once 'sessionCheck2.php'; $ Query = $ con - & gt; Leave Query ("SELECT movies.id, movies.image, movies.movie_name, AVG (user_movie_ratings.rating) as ratings from movies, User_movie_artings movies in doubles. User_movie_writing.movi_id group.im movies"); $ MovieTitle = Array (); While ($ line = $ query-> fetch_object ()) {$ movieTitle [] = $ line; }? & Gt; & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Title & gt; Home and lt; / Title & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = ISO-8859-1" /> & Lt; Link rel = "stylesheet" type = "text / css" href = "styles.css" /> & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "wrapper" & gt; & Lt; Div id = "header" & gt; & Lt; Div id = "h1" & gt; & Lt; / Div & gt; & Lt; Div id = "login" & gt; & Lt ;? Include Php // 'loginCheck.php' ;? & Gt; & Lt ;? Php included 'login.php' ;? & Gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div id = "movies" & gt; & Lt ;? Php foreach ($ movieTitle $ as Movie):? & Gt; & Lt ;? Php echo "
  • . '& Lt; Img src = "'. $ Movie-> Image." "/ & Gt; ';? & Gt; & lt; div class =" CFF "& gt; & gt; Php echo $ movie- & gt; movie_name;? & Gt; & lt; / div & gt; Lt; div class = "s11 c999" & gt; Rating: & lt ;? php echo round ($ movie- & gt; rating);? & Gt; & lt; / div> & lt ;? php echo & Lt; / Li & gt; & Lt; / Ul & gt; "?; & Gt; & lt; / div & gt; & lt ;? php endforeach;? & Gt; div id =" footer "& gt; This footer is & lt; / Div & gt; & gt; / div> & lt; / body & gt; & lt; / html & gt;

node.js - request.post continues to override content-type as content-type: application/x-www-form-urlencoded when form-data is being specified -


We have a client API call for which it must be sent as a post form-data. When we run calls via Chrome's Postman Extension, we specify form-data, and if we specify the x-www-form-urlxod, then it is executed successfully by returning an error. This is expected.

However, when we try to run the "request" NPM package to handle the post, we will continue to get an error message from the API, which is unfortunate to us. Do not direct us from what is wrong. But we see that when requested that the requested title item looks like this:

_header: 'POST / API / client / coupon / add HTTP / 1.1 \ r \ n authorization : Original [auth string redacted] \ r \ nhost: beta1.client.com \ r \ ncontent-type: application / x-www-form-urlencoded \ r \ n Content-Length: 172 \ r \ n Connection: Alive \ r \ n \ r \ n ',

our node. Js code looks like this:

  // create coupon code coupon = {code: "abcde1234"), discount: "33", type: "percent"} var request = requirement ('request '); Request.post ({url: "https://beta1.client.com/api/coupon/add", header: {"authorization": auth, "content-disposition": "form-data; name = 'data' "}, Form: coupon}, function (error, feedback, body) {if (! Error and response.statusCode == 200) {console.log (body)}});  

Am I wondering why content-type header continues to read "application / x-www-form-url encode" when we have the content of 'form-data' The arrangement is provided. I feel that if I can remove the content type header, then it should work - but how to do it?

Any insights will be appreciated.

content-type header application / x-www- Form-urlencoded because you are using form in your post request.

  request.post ({url: "https://beta1.client.com/api/ coupon / add", header: {"authorization": auth, "content-disposition": "Form-data; name = 'data'"}, form: coupon}, function (error, response, body) {...});  

To control it, you must add content as body as given below.

  request.post ({Url: "https://beta1.client.com/api/coupon/add", header: {"authorization": auth, "content-disposition": "Form-data; name = 'data'"}, body: coupon}, function (error, reaction, body) {...});  

eclipse - Hibernate error while compiling -


I am attempting to include Hibernate v4 in my dynamic web project in Eclipse I am using Maven for Dependency I have written all the code and have created unit sections and mapping XML files but on the building project I get this error

  This project was not created because its build path is incomplete Javax Class F for .name Il eluded. Fix the build path, try creating this project. MyProject  

I wrote the hibernate youth class as:

  import org.hibernate. SessionFactory; Import org.hibernate.boot.registry.StandardServiceRegistryBuilder; Import org.hibernate.cfg.configuration; Import org.hibernate.service.ServiceRegistry; Public Class Hibernate Youths {Private Status Session Session. Factory = buildSessionFactory (); Private Static Session Facial Fabrication (FACT) {try (sessionFactory == empty) {configuration configuration = new configuration (). Configure (Hibernate Utility Class.getResource ("/ hibernate.cfg.xml")); StandardServiceRegistryBuilder Service RegistryBuilder = New StandardServiceRegistryBuilder (); ServiceRegistryBuilder.applySettings (Configuration .getProperties ()); ServiceRegistration ServiceResearch = ServiceRajistBiller Builder (); SessionFactory = Configuration .buildSessionFactory (serviceRegistry); } Return session; } Catch (Throttle Pre) {System.err.println ("Initial Session. Factoring Failure." + East); New ExceptionInInitializerError (ex) Throw; }} Public stable session - Factory getSessionFactory () {Return Session Factory; } Public static void close () {getSessionFactory () Close (); }}  

EDIT: I get this error on the GetSessionFactory method call in the shutdown method. Anyone know what the problem might be?

It is not available on the class build path as it says, you have to fix the build path. Do this by giving a package that is javax.naming.Referenceable.

What makes me feel strange is to rewrite the hibernate unit? There is probably nothing that you want to do here. And I'm not getting any explanation why you write your own.

I recommend forgetting the hibernate uplit class and starting the hibernate framework completely.


hadoop - How to use Yarn to allocate more resources to a job -


I have some different functions to run on a Hadoop cluster. I need some resources and something else, eg . remember. I would like to run these tasks together on my cluster because it supports yarns. I think if I only collect jobs in the cluster, then the yarn automatically decides the processing requirements, although I myself I want to specify how can I use the API or command line to specify every work resource requirements?

You can set up memory by using JobConf for mapper and reducer, from the command line or Can do in your driver's class.

Set these properties to a specific setMemoryForMapTask and there are more information and usage details in SetMemoryForredSetsk (Long MEM)

.


Update error rails (stack level too deep) -


मुझे एक विशेषता स्वीकृत अद्यतन करते समय रेल में एक त्रुटि का सामना करना पड़ रहा है। स्वीकृत एक बूलियन प्रकार coloumn है।

यह कोड है:

  def प्रतिक्रिया अगर params [: प्रतिक्रिया ] @ इंवेट = आमंत्रित करें: आमंत्रित करें (आमंत्रित: '2') @ आमंत्रित.अपडेट (स्वीकार किए जाते हैं: परम [: प्रतिक्रिया]) रेंडर नहीं है: सच अंत समाप्ति  

ट्रेस (छवि के लिए खेद है) ):

यहां छवि विवरण दर्ज करें त्रुटि स्टैक स्तर बहुत गहरा है

मुझे लगता है कि जब आप update कार्रवाई कर रहे हैं और पासिंग कर रहे हैं पराम [: प्रतिक्रिया] , किसी भी तरह से यह प्रतिक्रिया क्रिया को शुरू कर रहा है और एक अनंत लूप में गिरता है, जो 'स्टैक लेवल बहुत गहरी' त्रुटि को बढ़ा रहा है

समस्या को ठीक करने के लिए प्रतिक्रिया को बदलें update_response या कुछ और।

  def update_response यदि पैरामीटर [: प्रतिक्रिया ] @ इंवेट = आमंत्रित करें: आमंत्रित करें (आमंत्रित: '2') @ आमंत्रित.अपडेट (स्वीकार किए जाते हैं: परम [: प्रतिक्रिया]) कुछ रेंडर नहीं करती: सच अंत समाप्ति  

जैसे ही मुझे कोई स्पष्टीकरण मिलता है, इस उत्तर को अपडेट करें।


opengl - glGetUniformLocation using a lot of CPU -


Is it normal when I call glGetUniformLocation in my render loop only once , Then the CPU usage process goes up to 30-40%? Should I call this method only once and store space in memory?

This is my code:

  glutton shader :: getUniform (const std :: string and name) Const {return glGetUniformLocation (m_programId, name.c_str ()); }  

Should I call this method only once and store Should store location in?

Yes, this will be the usual procedure either, or experiment.