Search Results

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

Page 60/297 | < Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >

  • passing argument 1 of 'atoi' makes pointer from integer without a cast....can any body help me..

    - by somasekhar
    #include<stdio.h> #include<string.h> #include<stdlib.h> int main(){ int n; int a,b,ans[10000]; char *c,*d,*e; int i = 0; c = (char*)(malloc(20 * sizeof(char))); d = (char*)(malloc(20 * sizeof(char))); scanf("%d",&n); while(i < n){ scanf("%d",&a); scanf("%d",&b); itoa(a,c,10); itoa(b,d,10); a = atoi(strrev(c)) + atoi(strrev(d)); itoa(a,c,10); e = c; while(*e == '0')e++; ans[i] = atoi(strrev(e)); i++; } i = 0; while(i < n){ printf("%d\n",ans[i]); i++; } }

    Read the article

  • In datastore, confused on how to pass a list of key_names as an argument to somemodel.get_or_insert(

    - by indiehacker
    Are there examples of how to pass a list of key_names to Model.get_or_insert() ? My Problem: With a method of ParentLayer I want to make the children. The key_names of the new (or editable) entities of class Child will come from such a list below: namesList = ["picture1","picture2"] so I should be able to build a list of key_names with method from the parent class as follows: class ParentLayer(db.Model): def getOrMakeChildren(self, namesList): keyslist = [ db.Key.from_path( 'Child' , name , parent = self.key() ) for name in namesList ] the problem is next where I simply want to get_or_insert entities based on keylist defined above: childrenEntitiesList = Child.get_or_insert(keyslist) # no works? also none of the below attempts worked: #childrenEntitiesList = Child.get_or_insert(keyslist, parent = u'TEST') #childrenEntitiesList = Child.get_or_insert(keyslist, parent=self.key().name() ) #childrenEntitiesList = Child.get_or_insert(keyslist, parent=self.key()

    Read the article

  • How to tell a method has a varargs argument using reflection?

    - by Anthony Kong
    Here is a sample code package org.example; import java.lang.reflect.Method; class TestRef { public void testA(String ... a) { for (String i : a) { System.out.println(i); } } public static void main(String[] args){ Class testRefClass = TestRef.class; for (Method m: testRefClass.getMethods()) { if (m.getName() == "testA") { System.out.println(m); } } } } The output is public void org.example.TestRef.testA(java.lang.String[]) So the signature of the method is reported to take a array of String. Is there any mean in the reflection library I can tell that the method is originally declared to take a varargs?

    Read the article

  • Rails Tutorial Chapter 4 2nd Ed. Title Helper not being called with out argument.

    - by SuddenlyAwakened
    I am running through the Rails Tutorial by Michael Hartl (Screen Cast). Ran into the and issue in chapter 4 on the title helper. I have been putting my own twist on the code as I go to make sure I understand it all. However on this one I it is very similar and I am not quite sure why it is acting the way it is. Here is the code: Application.html.erb <!DOCTYPE html> <html> <head> <%- Rails.logger.info("Testing: #{yield(:title)}") %> <title><%= full_title(yield(:title)) %></title> <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> </head> <body> <%= yield %> </body> </html> Application_helper.rb module ApplicationHelper def full_title(page_title) full_title = "Ruby on Rails Tutorial App" full_title += " | #{page_title}" unless page_title.blank? end end Home.html.erb <h1><%= t(:sample_app) %></h1> <p> This is the home page for the <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a> sample application </p> about.html.erb <% provide(:title, t(:about_us)) %> <h1><%= t(:about_us) %></h1> <p> The <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a> is a project to make a book and screencast to teach web development with <a href="http://railstutorial.org/">Ruby on Rails</a>. This is the sample application for the tutorial. </p> What Happens: The code works fine when I set the provide method like on the about page. However when I do not it does not seem to even call the helper. I am assuming that because no title is passed back. Any ideas on what I am doing wrong? Thank you all for your help.

    Read the article

  • How do I use a string as a keyword argument?

    - by Issac Kelly
    Specifically, I'm trying to use a string to arbitrairly filter the ORM. I've tried exec and eval solutions, but I'm running into walls. The code below doesn't work, but it's the best way I know how to explain where I'm trying to go from gblocks.models import Image f = 'image__endswith="jpg"' # Would be scripted in another area, but passed as text <user input> d = Image.objects.filter(f) #for the non-django pythonistas: d = Image.objects.filter(image__endswith="jpg") # would be the non-dynamic equivalent.

    Read the article

  • Help with Java Generics: Cannot use "Object" as argument for "? extends Object"

    - by AniDev
    Hello, I have the following code: import java.util.*; public class SellTransaction extends Transaction { private Map<String,? extends Object> origValueMap; public SellTransaction(Map<String,? extends Object> valueMap) { super(Transaction.Type.Sell); assignValues(valueMap); this.origValueMap=valueMap; } public SellTransaction[] splitTransaction(double splitAtQuantity) { Map<String,? extends Object> valueMapPart1=origValueMap; valueMapPart1.put(nameMappings[3],(Object)new Double(splitAtQuantity)); Map<String,? extends Object> valueMapPart2=origValueMap; valueMapPart2.put(nameMappings[3],((Double)origValueMap.get(nameMappings[3]))-splitAtQuantity); return new SellTransaction[] {new SellTransaction(valueMapPart1),new SellTransaction(valueMapPart2)}; } } The code fails to compile when I call valueMapPart1.put and valueMapPart2.put, with the error: The method put(String, capture#5-of ? extends Object) in the type Map is not applicable for the arguments (String, Object) I have read on the Internet about generics and wildcards and captures, but I still don't understand what is going wrong. My understanding is that the value of the Map's can be any class that extends Object, which I think might be redundant, because all classes extend Object. And I cannot change the generics to something like ? super Object, because the Map is supplied by some library. So why is this not compiling? Also, if I try to cast valueMap to Map<String,Object>, the compiler gives me that 'Unchecked conversion' warning. Thanks!

    Read the article

  • Spring Jdbc Template + MySQL = TransientDataAccessResourceException : Invalid Argument Value : Java.

    - by Vanchinathan
    I was using spring jdbc template to insert some data into the database and I was getting this error. Here is my code : JdbcTemplate insert = new JdbcTemplate(dataSource); for(ResultType result : response.getResultSet().getResult()) { Object[] args = new Object[] {result.getAddress(), result.getCity(), result.getState(), result.getPhone(), result.getLatitude(), result.getLongitude(),result.getRating().getAverageRating(), result.getRating().getAverageRating(), result.getRating().getTotalRatings(), result.getRating().getTotalReviews(), result.getRating().getLastReviewDate(), result.getRating().getLastReviewIntro(), result.getDistance(), result.getUrl(), result.getClickUrl(), result.getBusinessUrl(), result.getBusinessClickUrl()}; insert.update("INSERT INTO data.carwashes ( address, city, state, phone, lat, lng, rating, average_rating, total_ratings, total reviews, last_review_date, last_review_intro, distance, url, click_url, business_url, business_click_url, category_id, zipcode_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,96925724,78701)", args); } Quite lengthy code.. but, basically it gets the value from a object and sticks it to a array and passed that array to insert method of jdbc template. Any help will be appreciated.

    Read the article

  • how to pass javascript function argument within JSF component?

    - by Milan
    Hello everybody! I have the folowing code: <script Language="JavaScript"> function load(url) { var load = window.open(url,'','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no'); } </script> <h:commandLink value="aaa" onclick="load('<h:outputText value="http://www.google.com" /> '); /> I want to pass attribute in JS function but probably inside onclick is not the right way. Any solution?

    Read the article

  • How to use a class's type as the type argument for an inherited collection property in C#

    - by Edelweiss Peimann
    I am trying to create a representation of various types of card that inherit from a generic card class and which all contain references to their owning decks. I tried re-declaring them, as suggested here, but it still won't convert to the specific card type. The code I currently have is as such: public class Deck<T> : List<T> where T : Card { void Shuffle() { throw new NotImplementedException("Shuffle not yet implemented."); } } public class Card { public Deck<Card> OwningDeck { get; set; } } public class FooCard : Card { public Deck<FooCard> OwningDeck { get { return (Deck<FooCard>)base.OwningDeck; } set { OwningDeck = value; } } } The compile-time error I am getting: Error 2 Cannot convert type 'Game.Cards.Deck' to 'Game.Cards.Deck' And a warning suggesting I use a new operator to specify that the hiding is intentional. Would doing so be a violation of convention? Is there a better way? My question to stackoverflow is this: Can what I am trying to do be done elegantly in the .NET type system? If so, can some examples be provided?

    Read the article

  • Why is passing a string literal into a char* argument only sometimes a compiler error?

    - by Brian Postow
    I'm working in a C, and C++ program. We used to be compiling without the make-strings-writable option. But that was getting a bunch of warnings, so I turned it off. Then I got a whole bunch of errors of the form "Cannot convert const char* to char* in argmuent 3 of function foo". So, I went through and made a whole lot of changes to fix those. However, today, the program CRASHED because the literal "" was getting passed into a function that was expecting a char*, and was setting the 0th character to 0. It wasn't doing anything bad, just trying to edit a constant, and crashing. My question is, why wasn't that a compiler error? In case it matters, this was on a mac compiled with gcc-4.0. EDIT: added code: char * host = FindArgDefault("EMailLinkHost", ""); stripCRLF(linkHost, '\n'); where: char *FindArgDefault(char *argName, char *defVal) {// simplified char * val = defVal; return(val); } and void stripCRLF(char *str, char delim) { char *p, *q; for (p = q = str; *p; ++p) { if (*p == 0xd || *p == 0xa) { if (p[1] == (*p ^ 7)) ++p; if (delim == -1) *p = delim; } *q++ = *p; } *q = 0; // DIES HERE } This compiled and ran until it tried to set *q to 0...

    Read the article

  • why does .replace method use forward slash characters to enclose the first argument?

    - by Phillip Dodd
    I am working through a book about Javascript and have encountered the following example of code designed to replace the value of the class attribute of a table header HTML element: th.className = th.className.replace(/asc/,"dsc"); th.className = th.className.replace(/dsc/,"asc"); Why is the first parameter of .replace, the current value of th.className, enclosed in forward slashes instead of quotation marks? Why not use quotation marks to enclose both parameters, not just the second one? Thank you in advance for any help given. First time posting, apologies if I duplicated a question despite searching the site before posting.

    Read the article

  • How to create a function and pass in variable length argument list?

    - by Jian Lin
    We can create a function p in the following code: var p = function() { }; if (typeof(console) != 'undefined' && console.log) { p = function() { console.log(arguments); }; } but the arguments are passed like an array to console.log, instead of passed one by one as in console.log(arguments[0], arguments[1], arguments[2], ... Is there a way to expand the arguments and pass to console.log like the way above? Note that if the original code were var p = function() { }; if (typeof(console) != 'undefined' && console.log) { p = console.log; } then it works well on Firefox and IE 8 but not on Chrome.

    Read the article

  • CLR: Multi Param Aggregate, Argument not in Final Output?

    - by OMG Ponies
    Why is my delimiter not appearing in the final output? It's initialized to be a comma, but I only get ~5 white spaces between each attribute using: SELECT [article_id] , dbo.GROUP_CONCAT(0, t.tag_name, ',') AS col FROM [AdventureWorks].[dbo].[ARTICLE_TAG_XREF] atx JOIN [AdventureWorks].[dbo].[TAGS] t ON t.tag_id = atx.tag_id GROUP BY article_id The bit for DISTINCT works fine, but it operates within the Accumulate scope... Output: article_id | col ------------------------------------------------- 1 | a a b c I only have rudimentary C# API knowledge... C# Code: using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; using System.Xml.Serialization; using System.Xml; using System.IO; using System.Collections; using System.Text; [Serializable] [SqlUserDefinedAggregate(Format.UserDefined, MaxByteSize = 8000)] public struct GROUP_CONCAT : IBinarySerialize { ArrayList list; string delimiter; public void Init() { list = new ArrayList(); delimiter = ","; } public void Accumulate(SqlBoolean isDistinct, SqlString Value, SqlString separator) { delimiter = (separator.IsNull) ? "," : separator.Value ; if (!Value.IsNull) { if (isDistinct) { if (!list.Contains(Value.Value)) { list.Add(Value.Value); } } else { list.Add(Value.Value); } } } public void Merge(GROUP_CONCAT Group) { list.AddRange(Group.list); } public SqlString Terminate() { string[] strings = new string[list.Count]; for (int i = 0; i < list.Count; i++) { strings[i] = list[i].ToString(); } return new SqlString(string.Join(delimiter, strings)); } #region IBinarySerialize Members public void Read(BinaryReader r) { int itemCount = r.ReadInt32(); list = new ArrayList(itemCount); for (int i = 0; i < itemCount; i++) { this.list.Add(r.ReadString()); } } public void Write(BinaryWriter w) { w.Write(list.Count); foreach (string s in list) { w.Write(s); } } #endregion }

    Read the article

  • How to convert value of Generic Type Argument to a concrete type?

    - by Aleksey Bieneman
    I am trying to convert the value of the generic type parameter T value into integer after making sure that T is in fact integer: public class Test { void DoSomething<T>(T value) { var type = typeof(T); if (type == typeof(int)) { int x = (int)value; // Error 167 Cannot convert type 'T' to 'int' int y = (int)(object)value; // works though boxing and unboxing } } } Although it works through boxing and unboxing, this is an additional performance overhead and i was wandering if there's a way to do it directly. Thank you!

    Read the article

  • How to pass argument to a Microsoft Word macro ?

    - by Nam Gi VU
    I need to run a macro in Word with a parameter. I've tried to declare a parameter for the module in the VB Macro Editor but it doesn't work - the macro will be invisible in the macro list when I do so. I don't know how to do this and whether it is posible to do so or not in MS Word 2007. Please help.

    Read the article

  • How to know if the argument that is passed to the function is a class, union or enum in c++?

    - by Narek
    I want to define an operator<< for all enums, to cout the value and print that it is an enum like this: code: enum AnyEnum{A,B,C}; AnyEnum enm = A; cout << enm <<endl; output: This is an enum which has a value equal to 0 I know a way of doing this with Boost library by using is_enum struct. But I don’t understand how it works. So that's why, in general, I am interested how to identify if the veriable is a class type, union type or an enum (in compile time).

    Read the article

  • Specified argument was out of the range of valid values. Parameter name: utcDate

    - by Rob
    Our logs show hundreds of these errors after our deployment if users are on the site. Anyone know what this means and how to fix it? Notes: We are using msdeploy, IIS 6 I recently noticed that our web server's time is about 10 minutes behind the real time, I think that may have something to do with it. If I log into our site, seems like any file that depends on a WebResource or ScriptResource type file doesn't look right. Seems to fix itself after an IIS reset

    Read the article

  • How to fill a structure when a pointer to it, is passed as an argument to a function

    - by Ram
    I have a function: func (struct passwd* pw) { struct passwd* temp; struct passwd* save; temp = getpwnam("someuser"); /* since getpwnam returns a pointer to a static * data buffer, I am copying the returned struct * to a local struct. */ if(temp) { save = malloc(sizeof *save); if (save) { memcpy(save, temp, sizeof(struct passwd)); /* Here, I have to update passed pw* with this save struct. */ *pw = *save; /* (~ memcpy) */ } } } The function which calls func(pw) is able to get the updated information. But is it fine to use it as above. The statement *pw = *save is not a deep copy. I do not want to copy each and every member of structure one by one like pw-pw_shell = strdup(save-pw_shell) etc. Is there any better way to do it? Thanks.

    Read the article

  • Will the template argument's destructor to a templated class be called on deletion?

    - by Mutmansky
    If you have a templated base class as in the following example: class A{ A(); virtual ~A(); }; template <class T> class B : public T { B(); virtual ~B(); }; typedef B<A> C; class D : public C { D(); virtual ~D(); }; When you delete an instance of D, will the destructor of A be called? I'll probably create a test program to find out what happens, but just thinking about it, I wasn't sure what should happen.

    Read the article

  • Wildcards in jnlp template file

    - by Andy
    Since the last security changes in Java 7u40, it is required to sign a JNLP file. This can either be done by adding the final JNLP in JNLP-INF/APPLICATION.JNLP, or by providing a template JNLP in JNLP-INF/APPLICATION_TEMPLATE.JNLP in the signed main jar. The first way works well, but we would like to allow to pass a previously unknown number of runtime arguments to our application. Therefore, our APPLICATION_TEMPLATE.JNLP looks like this: <?xml version="1.0" encoding="UTF-8"?> <jnlp codebase="*"> <information> <title>...</title> <vendor>...</vendor> <description>...</description> <offline-allowed /> </information> <security> <all-permissions/> </security> <resources> <java version="1.7+" href="http://java.sun.com/products/autodl/j2se" /> <jar href="launcher/launcher.jar" main="true"/> <property name="jnlp...." value="*" /> <property name="jnlp..." value="*" /> </resources> <application-desc main-class="..."> * </application-desc> </jnlp> The problem is the * inside of the application-desc tag. It is possible to wildcard a fixed number of arguments using multiple argument tags (see code below), but then it is not possible to provide more or less arguments to the application (Java Webstart will no start with an empty argument tag). <application-desc main-class="..."> <argument>*</argument> <argument>*</argument> <argument>*</argument> </application-desc> Does someone can confirm this problem and/or has a solution for passing a previously undefined number of runtime arguments to the Java application? Thanks alot!

    Read the article

  • How do I convert from unicode to single byte in C#?

    - by xarzu
    How do I convert from unicode to single byte in C#? This does not work: int level =1; string argument; // and then argument is assigned if (argument[2] == Convert.ToChar(level)) { // does not work } And this: char test1 = argument[2]; char test2 = Convert.ToChar(level); produces funky results. test1 can be: 49 '1' while test2 will be 1 ''

    Read the article

  • How to close Blackberry map programmatically

    - by nhd
    Hi all, please help me close Blackberry map programmatically from my application. I first call BB map and pass a map argument and it display seem smoothly, but in the second, when I change my map argument, BB map doesn't respond with the new argument, it keeps the old. I think I must close it before pass the new argument but don't know how to do that. Thank you.

    Read the article

< Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >