Search Results

Search found 7418 results on 297 pages for 'argument passing'.

Page 159/297 | < Previous Page | 155 156 157 158 159 160 161 162 163 164 165 166  | Next Page >

  • How, exactly, does the double-stringize trick work?

    - by Peter Hosey
    At least some C preprocessors let you stringize the value of a macro, rather than its name, by passing it through one function-like macro to another that stringizes it: #define STR1(x) #x #define STR2(x) STR1(x) #define THE_ANSWER 42 #define THE_ANSWER_STR STR2(THE_ANSWER) /* "42" */ Example use cases here. This does work, at least in GCC and Clang (both with -std=c99), but I'm not sure how it works in C-standard terms. Is this behavior guaranteed by C99? If so, how does C99 guarantee it? If not, at what point does the behavior go from C-defined to GCC-defined?

    Read the article

  • ASP.Net: User control with content area, it's clearly possible but I need some details.

    - by bert
    I have seen two suggestions for my original question about whether it is possible to define a content area inside a user control and there are some helpful suggestions i.e. http://stackoverflow.com/questions/1971498/passing-in-content-to-asp-net-user-control and http://stackoverflow.com/questions/1912283/asp-net-user-control-inner-content Now, I like the theory of the latter better than the former just for aesthetic reasons. It seems to make more sense to me but the example given uses two variables content and templateContent that the answerer has not defined in their example code. Without these details I have found that the example does not work. I guess they are properties of the control? Or some such? The former example seems workable but I'd prefer to go with the latter if someone could fill in the blanks for me. Thanks.

    Read the article

  • How get file path from std::ifstream in c++

    - by Nilesh Shinge
    Hi All I am opening file using C++ function std::ifstream. I may open file using relative path (file.txt) or absoulte path (C:\test\file.txt). As I am passing string as file name, dont know whether it is relative or absolute path. Can any body tell me how to get absolutre path after file has been successfully open using std::ifstream function. e.g. std::ifstream file(strFile); // strFile = "file.txt" or strFile = "C:\test\file.txt" I want absolute path after file open successfully. Thanks Nilesh

    Read the article

  • 2 Classes need each other declared C++

    - by Prodigga
    I have a "Game" class which holds all the games settings and manages the game. I have a "Grid" class which is the grid the game is played on. The "Game" class initializes a "Grid" object as one of its members (passing itself ("this") as one of the parameters for "Grid"s constructor).. The "Grid" object therefor needs to deal with a "Game*" pointer. To do this it needs to know what "Game" is; i need to declare it before "Grid". But "Game" uses "Grid"...so it also needs "Grid" declared before it. so confused on how to include headers/etc correctly here..

    Read the article

  • What are the advantages to use StringBuilder versus XmlDocument or related to create XML documetns?

    - by Rob
    This might be a bit of a code smell, but I have seen it is some production code, namely the use of StringBuilder as opposed to XmlDocument when creating XML documents. In some cases these are write once operations (e.g. create the document and save it to disk) where as others are passing the built string to an XmlDocument to preform an XslTransform to a document that is returned to the client. So obvious question: is there merit to doing things this way, is it something that should be done on a case-by-case basis, or is this the wrong way of doing things?

    Read the article

  • how to pass an array into an function and in the function count how many numbers are in a range?

    - by user320950
    #include <iostream> #include <fstream> using namespace std; int calculate_total(int exam1[], int exam2[], int exam3[]); // function that calcualates grades to see how many 90,80,70,60 int exam1[100];// array that can hold 100 numbers for 1st column int exam2[100];// array that can hold 100 numbers for 2nd column int exam3[100];// array that can hold 100 numbers for 3rd column // here i am passing an array into the function calcualate_total int calculate_total(exam1[],exam2[],exam3[]) { int above90=0, above80=0, above70=0, above60=0; if((num<=90) && (num >=100)) { above90++; { if((num<=80) && (num >=89)) { above80++; { if((num<=70) && (num >=79)) { above70++; { if((num<=60) && (num >=69)) { above60++; } } } } } } } }

    Read the article

  • Cakephp session is not setting in pages controller

    - by binoy
    Hi, I am using cakephp1.2 . I have override the pages controller. While login from my application, Im setting the session and redirecting to pages controller, but there I could not able to get the session. If I redirect to some other controller, Im getting the session over there. I have a table with name "pages", and when the user clicks on the links (passing page name), Im taking data from that table and displaying using pages_controller. Can I not use "pages" as table name ? Or session won't work in pages_controller ?

    Read the article

  • Correct way to safely store token/secret/etc from OAuth?

    - by viatropos
    I just started looking into OAuth and it looks really nice. I have oauth with twitter working in ruby right now. Now I'm wondering, what is the recommended safe way to store the responses in my local database and session? What should I store? Where should I store it? This example twitter-oauth-with-rails app stores a user.id in the session, and the user table has the token and secret. But that seems like it'd be really easy to hack and get the secret by just passing in a slew of test user ids, no?

    Read the article

  • How to reference an anonymous JavaScript function?

    - by ProfK
    I'm trying to call a Page Method using a jQuery 'attached' event function, in which I like to use the closure to keep the event target local, as below, but page method calls declare several 'error' functions, and I would like to use one function for all of them. If, in the below code, I was handling an error and not success, how could I use my single, anonymous handler for all 3 error functions? $(":button").click(function () { var button = this; PageMethods.DoIt( function (a, b, c) { alert(button); }); }); This example passes an anonymous function for the success callback. There is only one of these. If I was passing an error callback, how could I use 'function (e, c, t)' for all 3 error callbacks?

    Read the article

  • Decreasing lagging on router, while gaming

    - by user2699451
    I had absolutely no idea where to post this question and get a professional answer for it but here goes... Okay, so I guess everyone whos is reading this had played online, and so I was playing LoL again tonight and my brother decided that now was a great time to go on youtube and start watching a movie, so my ping (connecting from South Africa to EU west server) is around 190-220 average, however it started spiking to 2000 and average was 600-800, so it arised the question, how ther hell can I "kick" him off for the time being I tried reasoning it out with him but its like playing chess with a pigeon, he's studying to be an engineer, and I just cant win an argument with him, so i need to step it up a level... I have in the past used the aireplay method by sending deauth packets but it only helped so much, is there another way of either kicking a peer of the local wifi or decreasing the lag spikes while in session or even splitting the bandwidth equally in 2 or 3,etc What do I do p.s. sorry if off topic, if it is not appropriate, just say which website will be able to help or assist me...

    Read the article

  • Pass temporary object to function that takes pointer

    - by Happy Mittal
    I tried following code : #include<iostream> #include<string> using namespace std; string f1(string s) { return s="f1 called"; } void f2(string *s) { cout<<*s<<endl; } int main() { string str; f2(&f1(str)); } But this code doesn't compile. What I think is : f1 returns by value so it creates temporary, of which I am taking address and passing to f2. Now Please explain me where I am thinking wrong?

    Read the article

  • My AES encryption/decryption functions don't work with random ivecs

    - by Brendan Long
    I was bored and wrote a wrapper around openSSL to do AES encryption with less work. If I do it like this: http://pastebin.com/V1eqz4jp (ivec = 0) Everything works fine, but the default ivec is all 0's, which has some security problems. Since I'm passing the data back as a string anyway, I figured, why not generate a random ivec and stick it to the front, the take it back off when I decrypt the string? For some reason it doesn't work though. With random ivec: http://pastebin.com/MkDBFcn6 Well actually, it almost works. It seems to decrypt the middle of the string, but not the beginning or end: String is: 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF Encrypting.. ???l%%1u???B! ?????`pN)?????[l????{?Q???2?/?H??y"?=Z?Cu????l%%1u???B! Decrypting.. String is: ?%???G*?5J?0??0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF!-e????V?5 I honestly have no idea what's going wrong. Maybe some stupid mistake, or maybe I'm missing something about AES?

    Read the article

  • How Do I get the current instance from an AppDomain?

    - by Spanners
    Hi, I use the default appdomain (AD) which I use to create new appdomains (AD1) when required for running plugins in isolation. When creating the new domain I also wire up the AppDomainUnload event to allow me to call clean up code etc. The issue I seem to have is: 1) Create AD1 from AD 2) Run code in AD1 3) Call AD.Unload(AD1) The code switches to AD1 and calls the unloading event passing in a reference to the current AppDomain (AD1). At this point I'd like to get a reference to the current instance running in AD1 to call a shutdown method however there is no GetInstance on the AppDomain class. Any ideas how I can go about getting it?

    Read the article

  • Does to_json require parameters? what about within rails?

    - by Harry Wood
    Does to_json require parameters? what about within rails? I started getting the error "wrong number of arguments (0 for 1)" when doing myhash.to_json Unfortunately I'm not sure when this error started happening, but I guess it relates to some versions of either rails or the json gem. I suppose my code (in a rails controller) is using the ActiveSupport::JSON version of to_json, rather than the to_josn method supported by the json gem. ActiveSupport::JSON vs JSON In environment.rb I have RAILS_GEM_VERSION = '2.3.2' and also config.gem "json", :version=> '1.1.7' It's just a simple hash structure containing primitives which I want to convert in my controller, and it was working, but now I can't seem to run to_json without passing parameters.

    Read the article

  • No-overflow cast on x64

    - by Cheeso
    I have an existing C codebase that works on x86. I'm now compiling it for x64. What I'd like to do is cast a size_t to a DWORD, and throw an exception if there's a loss of data. Q: Is there an idiom for this? Here's why I'm doing this: A bunch of Windows APIs accept DWORDs as arguments, and the code currently assumes sizeof(DWORD)==sizeof(size_t). That assumption holds for x86, but not for x64. So when compiling for x64, passing size_t in place of a DWORD argument, generates a compile-time warning. In virtually all of these cases the actual size is not going to exceed 2^32. But I want to code it defensively and explicitly. This is my first x64 project, so... be gentle.

    Read the article

  • How to gather usage statistics for iPhone app?

    - by FX
    I am in the process of releasing my first iPhone app. It's a simple utility, I'd just like to gauge the release process, app lifetime and trends, just so it can help make more realistic choices in future apps. I think it would be nice to have usage statistics in addition to download stats from Apple. For example, how many times is the app opened by each user, what iPhone OS version do they have, etc. I think some of it would simply be to try and connect to a known URL on one of my domains, passing it anonymous information (let's say, connect to http://mydomain.net/stats?app=myApp&version=1.0.0&os=3.1.2&used=18). My questions are: is that forbidden in any way by Apple's rules? (none that I could find, at least) does that seem reasonable to you? are there existing frameworks that would do that simpler/better that writing my own code?

    Read the article

  • Is there a way to use template specialization to separate new from new[]?

    - by Marlon
    I have an auto pointer class and in the constructor I am passing in a pointer. I want to be able to separate new from new[] in the constructor so that I can properly call delete or delete[] in the destructor. Can this be done through template specialization? I don't want to have to pass in a boolean in the constructor. template <typename T> class MyAutoPtr { public: MyAutoPtr(T* aPtr); }; // in use: MyAutoPtr<int> ptr(new int); MyAutoPtr<int> ptr2(new int[10]);

    Read the article

  • Pin same app multiple times in Windows 7

    - by Mr. Shiny and New ??
    I use some programs with command line arguments and like to have shortcuts for launching those programs with those arguments. For example, I keep several Firefox profiles around and like to specify the profile name on the command line. Similarly I have several Eclipse shortcuts with a command line argument specifying the workspace to open. I would like to be able to pin these shortcuts to the start menu or taskbar in Windows 7. The problem I have is that once I've pinned one of these, no other shortcuts which launch the same exe can be launched. I'm also open to suggestions such as a suitable desktop gadget which can contain a bunch of arbitrary shortcuts, yet remain in a fixed position on my desktop somewhere, or some way of adding a secondary taskbar (this was possible in XP).

    Read the article

  • Is this __import__ functionality correct?

    - by Jason Baker
    I have a package named jiva_tasks, which I'm trying to import via celery (using the CELERY_IMPORTS attribute of celeryconfig. The import statement that celery is using is this: __import__(module, [], [], ['']) Oddly enough, when this syntax is used, the module gets imported twice, once as jiva_tasks and another time as jiva_tasks. (with a period at the end). Now, chances are good that celery should be passing in globals rather than an empty list, but this seems broken to me. It seems odd that even if given the wrong arguments, __import__ would import something that isn't a valid python module name. I know that the way to fix this is to pass in globals, but I want to understand why I'm getting this result. Is this a bug, or is there something I don't understand about how __import__ is working? Update: It also seems to be working fine if I use importlib.

    Read the article

  • Jquery autocomplete for input form, using Textpattern category list as a source

    - by John Stephens
    I'm using the Textpattern CMS to build a discussion site-- I have a firm grasp of XHTML and CSS, as well as Textpattern's template language, but PHP and Javascript are a bit beyond my cunning. On the input form to begin a new topic, users need to select a category from a list of over 5,000 options. Using the HTML select-type input element is very unwieldy, but it works. I would like to use some kind of Javascript magic to display a text-type input element that will read user input and display matches or autocomplete from the available categories, passing the required option's value into the appropriate database field. I've seen several autocomplete plugins for jquery, but the instructions presuppose that you understand how Javascript works. As I mentioned above, it's easy for me to generate the category list as a select-type input element, and I can hide that element using CSS. Is it possible to control select-list input using an autocomplete mechanism in a text-type input element? How would I do that?

    Read the article

  • Best way to do something when a runloop event is done processing?

    - by quixoto
    I have some processing in my Cocoa app that sometimes ends up calling through a hierarchy of data to do a bunch of work as the result of an event. Each small piece creates and destroys some resources. I don't want those resources around most of the time, but I would like to find a smart way of creating them before all the work and killing them at the end. Short of creating the resources up front and then passing them entirely down through the call hierarchy when work is done, is there a way to know locally in some code when an event loop run has ended? Then I could create them if they're not there, and keep them until the run loop ends, reusing them for any subsequent calls before that time. Thanks.

    Read the article

  • How to dynamically order many-to-many relationship in JPA or HQl?

    - by Indrek
    I have a mapping like this: @ManyToMany(cascade = CascadeType.PERSIST) @JoinTable( name="product_product_catalog", joinColumns={@JoinColumn(name="product_catalog", referencedColumnName="product_catalog")}, inverseJoinColumns={@JoinColumn(name="product", referencedColumnName="product")}) public List<Product> products = new ArrayList<Product>(); I can fetch the products for the catalog nicely, but I can't (dynamically) order the products. How could I order them? I probably have to write a many-to-many HQL query with the order-by clause? I though of passing the orderBy field name string to the query, or is there a better solution? Tables are: products, product_catalog, product_product_catalog (associative table) P.S. Using Play! Framework JPASupport for my entities.

    Read the article

  • Recompiling an old fortran 2/4\66 program that was compiled for os\2 need it to run in dos

    - by Mike Hansen
    I am helping an old scientist with some problems and have 1 program that he found and modified about 20 yrs. ago, and runs fine as a 32 bit os\2 executable but i need it to run under dos! I am not a programmer but a good hardware & software man, so I'am pretty stupid about this problem, but here go's I have downloaded 6 different compilers watcom77,silverfrost ftn95,gfortran,2 versions of g77 and f80. Watcom says it is to old of program,find older compiler,silverfrost opens it,debugs, etc. but is changing all the subroutines from "real" to "complex" and vice-vesa,and the g77's seem to install perfectly (library links and etc.) but wont even compile the test.f programs.My problem is 1; to recompile "as is" or "upgrade" the code? PROGRAM xconvlv INTEGER N,N2,M PARAMETER (N=2048,N2=2048,M=128) INTEGER i,isign REAL data(n),respns(m),resp(n),ans(n2),t3(n),DUMMY OPEN(UNIT=1, FILE='C:\QKBAS20\FDATA1.DAT') DO 1 i=1,N READ(1,*) T3(i), data(i), DUMMY continue CLOSE(UNIT-1) do 12 i=1,N respns(i)=data(i) resp(i)=respns(i) continue isign=-1 call convlv(data,N,resp,M,isign,ans) OPEN(UNIT=1,FILE='C:\QKBAS20\FDATA9.DAT') DO 14 i=1,N WRITE(1,*) T3(i), ans(i) continue END SUBROUTINE CONVLV(data,n,respns,m,isign,ans) INTEGER isign,m,n,NMAX REAL data(n),respns(n) COMPLEX ans(n) PARAMETER (NMAX=4096) * uses realft, twofft INTEGER i,no2 COMPLEX fft (NMAX) do 11 i=1, (m-1)/2 respns(n+1-i)=respns(m+1-i) continue do 12 i=(m+3)/2,n-(m-1)/2 respns(i)=0.0 continue call twofft (data,respns,fft,ans,n) no2=n/2 do 13 i=1,no2+1 if (isign.eq.1) then ans(i)=fft(i)*ans(i)/no2 else if (isign.eq.-1) then if (abs(ans(i)) .eq.0.0) pause ans(i)=fft(i)/ans(i)/no2 else pause 'no meaning for isign in convlv' endif continue ans(1)=cmplx(real (ans(1)),real (ans(no2+1))) call realft(ans,n,-1) return END SUBROUTINE realft(data,n,isign) INTEGER isign,n REAL data(n) * uses four1 INTEGER i,i1,i2,i3,i4,n2p3 REAL c1,c2,hli,hir,h2i,h2r,wis,wrs DOUBLE PRECISION theta,wi,wpi,wpr,wr,wtemp theta=3.141592653589793d0/dble(n/2) cl=0.5 if (isign.eq.1) then c2=-0.5 call four1(data,n/2,+1) else c2=0.5 theta=-theta endif (etc.,etc., etc.) SUBROUTINE twofft(data,data2,fft1,fft2,n) INTEGER n REAL data1(n,data2(n) COMPLEX fft1(n), fft2(n) * uses four1 INTEGER j,n2 COMPLEX h1,h2,c1,c2 c1=cmplx(0.5,0.0) c2=cmplx(0.0,-0.5) do 11 j=1,n fft1(j)=cmplx(data1(j),data2(j) continue call four1 (fft1,n,1) fft2(1)=cmplx(aimag(fft1(1)),0.0) fft1(1)=cmplx(real(fft1(1)),0.0) n2=n+2 do 12 j=2,n/2+1 h1=c1*(fft1(j)+conjg(fft1(n2-j))) h2=c2*(fft1(j)-conjg(fft1(n2-j))) fft1(j)=h1 fft1(n2-j)=conjg(h1) fft2(j)=h2 fft2(n2-j)=conjg(h2) continue return END SUBROUTINE four1(data,nn,isign) INTEGER isign,nn REAL data(2*nn) INTEGER i,istep,j,m,mmax,n REAL tempi,tempr DOUBLE PRECISION theta, wi,wpi,wpr,wr,wtemp n=2*nn j=1 do 11 i=1,n,2 if(j.gt.i)then tempr=data(j) tempi=data(j+1) (etc.,etc.,etc.,) continue mmax=istep goto 2 endif return END There are 4 subroutines with this that are about 3 pages of code and whould be much easier to e-mail to someone if their able to help me with this.My e-mail is [email protected] , or if someone could tell me where to get a "working" compiler that could recompile this? THANK-YOU, THANK-YOU,and THANK-YOU for any help with this! The errors Iam getting are; 1.In a call to CONVLV from another procedure,the first argument was of a type REAL(kind=1), it is now a COMPLEX(kind=1) 2.In a call to REALFT from another procedure, ... COMPLEX(kind=1) it is now a REAL(kind=1) 3.In a call to TWOFFT from...COMPLEX(kind-1) it is now a REAL(kind=1) 4.In a previous call to FOUR1, the first argument was of a type REAL(kind=1) it is now a COMPLEX(kind=1).

    Read the article

  • Is it bad practice to use python's getattr extensively?

    - by Wilduck
    I'm creating a shell-like environment. My original method of handleing user input was to use a dictionary mapping commands (strings) to methods of various classes, making use of the fact that functions are first class objects in python. For flexibility's sake (mostly for parsing commands), I'm thinking of changing my setup such that I'm using getattr(command), to grab the method I need and then passing arguments to it at the end of my parser. Another advantage of this approach is not having to update my (currently statically implemented) command dictionary every time I add a new method/command. My question is, will I be taking a hit to the efficiency of my shell? Does it matter how many methods/commands I have? I'm currently looking at 30 some commands, which could eventually double.

    Read the article

  • jQuery/javascript events - prototype event handler

    - by Brian M. Hunt
    The following code doesn't work as I intuitively expect it to: function MyObject(input) { input.change(this._foo); this.X = undefined; } MyObject.prototype._foo = function() { alert("This code is never called"); // but if it did this.X = true; } var test_input = $("input#xyz"); // a random, existing input var m = MyObject(test_input); // attach handler (or try to) test_input.change(); // trigger event alert(m.X); // undefined I'd expect that _foo() would be called (and, if that ever happens, that the this variable in _foo() would be an instantiation of MyObject. Does anyone know why this doesn't work, and of any alternative pattern for passing an object to an event handler? Thank you for reading. Brian

    Read the article

< Previous Page | 155 156 157 158 159 160 161 162 163 164 165 166  | Next Page >