189 Discussion / Question Topics
Remove Filter Hi, How can I pass a c# string to C++ side of the app? Right now, I have all handling in Const char * format . When I pass c# string, c++ working fine when using Platform::String . But there is no good way of converting Platform::String to const char … | |
Hi, I am facing an issue in string to const char pointer conversion. I am doing stuff in the fun() but here i am just giving my example. Here it the code: // Helper function string fun() { string abc = "Daniweb"; // print here #1 return abc; } // … | |
Hi guys, Here is the question: I have Activity A, Activity B. Now, A --> B . Now, pressed the home button. Now, go to any image & "open with" will show my app. when pressing my app as the option, it will hit Activity A. When it will hit … | |
Hi everyone, How are you? Starting some thread after long time :) Actually, I have a group of 25 people. I have 20-25 mobile devices in my group. So, I have assigned 1-2 device on each person's name(as an owner). But, people in the group ask each other for the … | |
Hi, I have one function (in a library I can't change the code) which takes a key and returns a Object. This code is written in java. I am calling this function from cpp code. I am accepting the result as jobject. 1. Added key as "key1" & value as … | |
Hi, I have been working on JNI. I have one doubt. When I call any native method from android activity (Java code), then we get jclass object from jobject instance we get in the native method as a parameter. Why do we need it actually? Here is a snippet from … | |
Hi, I have one CSS. .buttonSize { min-width : 58% } Actually, I have two buttons, with text "Hovers" & "Copy". My button without any css taking spaces which can wrap the text size. This way size of two buttons is not same. What I tried: a) I have hacked … | |
Hey, I have been reading Java oracle tutorials. I read this thing. Suppose, for example, class MsLunch has two instance fields, c1 and c2, that are never used together. All updates of these fields must be synchronized, but there's no reason to prevent an update of c1 from being interleaved … | |
Hi, I have been working in Java for more than 8-9 months now. I want to have deep understanding of Java concepts now. For ex: Collections properties, threading, interfaces detailed concepts etc. I mean I have been using all these things for a while now but want to know about … | |
Hi all, Actually, this question is not related to some coding or logic from my project. But, as I am doing hard and harder projects (acc. to me & my exp.), I am focussing more on design part of my projects. When I present my design to team members for … | |
Hi, I am creating a form in jsp. <form action="" method="post"> <input type="hidden" name="status_1" value="0" /> <input type="checkbox" id="status_1" name="status_1" value="1" /> <input type="hidden" name="status_2" value="0" /> <input type="checkbox" id="status_2" name="status_2" value="1" /> <input type="hidden" name="status_3" value="0" /> <input type="checkbox" id="status_3" name="status_3" value="1" /> <input type="submit" /> </form> I was … | |
Hi, I am stuck with a problem. I have two Date objects (util class objects). I want the difference between these two dates as the number of days between them? I am using Java 8. Can you please help me with this? Searched the web a lot. Some are saying … | |
Hi, I was using booleans earlier in my class. --> isProductRestricted --> internal --> isProductGlobal I am using lombok too. So putting @Data at the top of class too. But, now I changed these boolean to Boolean variable. I got errors where ever `Object.isInternal()` was used. I am not getting … | |
Hey, I have one class Company and one Item class which is an object in Company class as shown: public abstract class Company { @Inject private ItemClass item; void companyMethod() { this.item.itemMethod(); } } public class ItemClass { public void itemMethod() { // logic } } So, many class inherits … | |
Hey, I have visited Daniweb after few months. I have seen "API" options in my profile. How can we use it? Is it similar to fb apis, twitter apis? Thanks. | |
public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ParseObject.registerSubclass(MyFirstClass.class); Parse.initialize(this, "Id", "Id"); Button button = (Button)findViewById(R.id.button1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { callSearch(); } }); ParseUser user = new ParseUser(); user.setUsername("username"); user.setPassword("password"); /*user.signUpInBackground(new SignUpCallback() { @Override public void done(ParseException arg0) { … | |
I have read few articles on google but I am still confused when to use what. I have come across checked and unchecked exceptions. I have one exception which I need to define. Let say, when xyz is null, I need to throw the inconsistentcyException which I will catch in … | |
Hi, Actually, I want to make one Singleton class which will create one instance for one thread. I mean if we have 10 threads, then Singleton will create only one object for one thread. IF same thread will ask for one more instance it will return the same instance. Basically, … | |
I built one Sync code. I am using eclipse for the same. Actually my code is working fine in eclipse. But when I run it in Tizen OS device. I am using beecrypt library for the same. I have one line auto_ptr<Mac>(Mac::getInstance("HmacSHA256")); Actually, it is throwing exception on this line. … | |
I have made very simple code to larn the functionality. String str = "ABC"; InputStream input = new ByteArrayInputStream(str.getBytes()); BufferedReader reader = new BufferedReader(new InputStreamReader(input)); System.out.println(Character.valueOf((char) reader.read())); System.out.println(reader.read()); System.out.println(reader.read()); System.out.print(reader.read()); Secondly this one, String str = "ABC"; InputStream input = new ByteArrayInputStream(str.getBytes("UTF-8")); System.out.print(input.read()); System.out.print(input.read()); } output is same for the … | |
I have one project named P2PTicTac. I have one file named layout.java. and one with CLient.java. I have made simple GridView in layout file with 9 buttons in 3*3 Grid. I have run two threads in client.java. One for reading the data from server and one for writing data to … | |
public class Input { static InputStream reader = null; /** * @param args * @throws IOException * @throws InterruptedException */ public static void main(String[] args) throws IOException, InterruptedException { Test test = new Test(); test.start(); String str = "1 21"; // Scanner scan = new Scanner(System.in); try { reader = … | |
I read about cherry-picking. It says: You have one branch x1 and branch x2. You want to take one commit from many commits of x2 and want to merge it with x1. You have 4-5 commits in x1 and now you take one commit or range of them and want … | |
I read many articles on Web regarding this. I am able to understand what static_cast does. I am not to properly understand why, and when we have to dynamic cast. There is something "we can downcast the pointer when it is polymorphic". I am not able to understand what they … | |
Hi, I am learning Git system these days. I have made a new folder in ubuntu and in terminal did this: 1. git init 2. then made a file testfile1.txt 3. then made a branch using "git branch newbranch" 4. then checkout to this branch. 5. then, made a new … | |
#include<iostream> using namespace std; class Singleton { static Singleton * s; Singleton() { } public: ~Singleton() { s = NULL; } static Singleton * getInstance(); void print() { cout<<this<<endl; } }; Singleton* Singleton::s=NULL; Singleton* Singleton::getInstance() { if(s == NULL) { s = new Singleton(); } return s; } int main() … | |
#include<iostream> using namespace std; int add(int x,int y) { int ans=0; int carry=0; for(int i=0;i<=31;i++) { int p = (1<<i)&x; int q = (1<<i)&y; int r = p ^ q; r = r^(carry<<i); ans = r | ans; if(p&q || p&(carry<<i) || q&(carry<<i)) carry = 1; else carry =0; } … | |
I have come across one question: find the size of two 2-D arrays when double pointers are given for them.Then find, if we can muliply these two matrices(those mathematics rules). finally we have to multiply the matrices. I have asked this question(small part of this question) earlier also. someone answered … | |
Why can we virtual destructors but can't have virtual constructors? I have searched like anything. I got confused a lot after reading few articles on web. Please explain with some good example. Thanks in advance. | |
I am working on a project and I need one CmakeList.txt file, Config file, spec file. I searched a lot. tutorials are telling how to make these files and all. Please tell me from scratch what they are and what is the use of these files? Please provide links also … | |
Can anyone give me an idea how to do this? I have a list(C++) of bytearray and I want to fire a post request to the server using CURL library? I have searched a lot and they say to set the CURL_POSTFIELDS but that requires a char * field. I … | |
I am damn confused between these two terms. Can anyone explain this using some example? Thanks in advance. | |
This problem is troubling me from so long time. There are N scientists, K black holes, and any scientist can query about radius, size and temperature of any blackhole. You have to answer three kinds of query basically: 1)Given Scientist queried for which blackholes,Given scientist queried for which attributes 2) … | |
int find(int x) { for(int i=0;i < n; i++) { if(a[i]==x) return i; } return -1; } int find(int x) { for(int i=0;i < n/2; i+=2) { if(a[i]==x) return i; if(i+1 < n && a[i+1]==x) return i+1; } return -1; } int find(int x) { for(int i=0;i < n/3; i+=3) … | |
Please tell me the difference between these three. I know the basic meaning but don't know exact meaning of all of them. Please explain a very good example if possible. Thanks in advance. | |
**With a 2^32 address space and 4K ( 2^12 ) page sizes, this leave 2^20 entries in the page table. At 4 bytes per entry, this amounts to a 4 MB page table, which is too large to reasonably keep in contiguous memory. ( And to swap in and out … | |
I am very confused with static functions. Can I override them? If no, then why? I searched web a lot but i am still not clear. Please tell with one example if possible. Thanks a lot. | |
I am using namespaces from a long time now. But, I don't know why we need them at the end? Why do I need to write using namespace std; OR std::string Why do we have to do this? Why have they made it this way? Can you elabroate this thing? … | |
I have learnt basic android in the last month. I have learnt about fragments, listview, adapters, acitivties, intents, content providers, databases, animations. I want some basic apps' ideas in which I can implement these things and can improve my learning? I am not too good in Java also. I know … | |
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; class Test{ public static void main(String args[]){ String Str = new String("WelcometoTutorialspoint.com-"); int i=0; System.out.println("Return Value :" ); for (String retval: Str.split("-", 2)){ System.out.println(retval); System.out.println(i); i++; } i=0; System.out.println(""); System.out.println("Return Value :" ); for (String … | |
**{"title":"iamtitle","icon":"","urlHistory":["http://google.com"],"lastUsed":123}** I have tried in c++ and using json-glib. I have tried using this: g_type_init(); JsonParser *parser = json_parser_new(); json_parser_load_from_data(parser, temp.c_str(), -1, NULL); JsonReader *reader = json_reader_new(json_parser_get_root(parser)); json_reader_read_member(reader,"urlHistory"); JsonNode * value = json_reader_get_value(reader); JsonArray * value1 = json_node_get_array(value); const char * urlhistory = json_array_get_string_element(value1,0); tab.history = urlhistory; json_reader_end_element(reader); cout << … | |
Does C++ consider \/ as an escape character? And does Java consider it? I am talking about forward and backslashes. Please tell. How does Java and C++ considers them differently? I mean : in C++: this '/' works fine without escape. in Java: this '\/' will result in '/'. Is … | |
I am creating one json array using Json-glib using c++. Here is the data: title="Daniweb" (string) last= 1234 (long) icon="icons" (string) url = "[\"dani.com\"]" (json array) After making one json array using exsiting APIs of json-glib library, I got this: {"id":"Nitin1","clientName":"Gourav_first_task","tabs":"[{\"title\":\"Daniweb\",\"icon\":\"icons\",\"urlHistory\":\"[\\\"Dani.com\\\"]\",\"lastUsed\":1234}]"} Is it the correct json string made? It has … | |
void func(void * ptr) { bytearray temp(10); *((bytearray*) ptr ) = temp; } This code is not going ahead if the third line while executing while this coding is working fine. void func(void * ptr) { const char * temp = "decept"; *((char*)ptr) = temp[0]; } Why is it happening? … | |
I am using Eclipse and there is one strange error coming while building. In files, it is not showing any error but when I build it, it says **Description Resource Path Location Type Program "g++ -std=c++0x" not found in PATH test [Discovery Options] page in project properties C/C++ Problem ** … | |
Today, I faced very weird problem. I have 2 classes say class A and B. Both have one .h and .cpp files. 4 files(A.cpp,B.cpp,A.h,B.h). A class is base class of B and we are using instance of B in class A. It was saying "not a type" error while compiling. … | |
I was just thinking that why I need headers at all? In headers, most oftenly we have the declarations only. In .cpp we have the definitons of that .h file. But, why can't we write all the functions directly in .h file and include it in my project files? Why … | |
For my project, I need to learn multithreading in C++. I have read 4-5 articles on Google, and have searched for more but they all are more or less similar. I want to learn it in depth. Can you provide me some links/source/anything for learning mutilthreading in C++? I am … | |
#include <iostream> using namespace std; class Time { private: int hours; // 0 to 23 int minutes; // 0 to 59 public: // required constructors Time(){ hours = 0; minutes = 0; } Time(int h, int m){ hours = h; minutes = m; } // method to display time void … | |
I am curious to know how I can make my own library and use it for my C/C++ programs? I mean I want to make a library say "maths_example" which will have 2-3 files having some basic functions of maths. Then, I want to use that library for my programs … |
The End.