Search Results

Search found 2101 results on 85 pages for 'c str'.

Page 17/85 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • why is strtof is always evaluating to HUGE_VAL?

    - by bstullkid
    What could be the issue here? It doesn't matter what number I choose for str, it is always 26815615859885194199148049996411692254958731641184786755447122887443528060147093953603748596333806855380063716372972101707507765623893139892867298012168192.00 char *str = "2.6"; printf("%f\n", strtof(str, (char**)NULL)); //prints 26815615859885194199148049996411692254958731641184786755447122887443528060147093953603748596333806855380063716372972101707507765623893139892867298012168192.00

    Read the article

  • javax.activation.DataSource size question

    - by folone
    How do I get the amount of physical memory, consumed by the DataSource (specifically — ByteArrayDataSource)? I use ByteArrayDataSource (byte[] bytes, String type) constructor, where I get bytes like this: String str = "test"; byte[] bytes = str.getBytes(); Would that be str.length() in bytes? Any other ideas?

    Read the article

  • C : Memory layout of C program execution

    - by pavun_cool
    Hi All , I wanted know how the kernel is providing memory for simple C program . For example : #include<stdio.h> #include<malloc.h> int my_global = 10 ; main() { char *str ; static int val ; str = ( char *) malloc ( 100 ) ; scanf ( "%s" , str ) ; printf( " val:%s\n",str ) ; } See, In this program I have used static , global and malloc for allocating dynamic memory So , how the memory lay out will be ... ? Any one give me url , which will have have details information about this process..

    Read the article

  • Is it safe to take the address of std::wstring's internal pointer?

    - by LCC
    I have an interface which is used like the following: if (SUCCEEDED(pInterface->GetSize(&size)) { wchar_t tmp = new wchar_t[size]; if (SUCCEEDED(pInterface->GetValue(tmp, size))) { std::wstring str = tmp; // do some work which doesn't throw } delete[] tmp; } Is it safe and portable to do this instead? if (SUCCEEDED(pInterface->GetSize(&size)) { std::wstring str; str.resize(size); if (SUCCEEDED(pInterface->GetValue(&str[0], size))) { // do some work } } Now, obviously this works (doesn't crash/corrupt memory) or I wouldn't have asked, but I'm mostly wanting to know if there's a compelling reason not to do this.

    Read the article

  • C#: how to construct strings

    - by Craig Johnston
    Which of these will achieve the correct result: (1) int X = 23; string str = "HELLO" + X.ToString() + "WORLD"; (2) int X = 23; string str = "HELLO" + X + "WORLD"; (3) int X = 23; string str = "HELLO" + (string)X + "WORLD"; EDIT: The 'correct' result is to output: HELLO23WORLD

    Read the article

  • How to read comma separated values from text file in JAVA?

    - by user1425223
    I have got this text file with latitude and longitude values of different points on a map. I want to store these coordinates into a mySQL database using hibernate. I want to know how can I split my string into latitudes and longitudes? What is the general way to do these type of things that is with other delimiters like space, tab etc.? File: 28.515046280572285,77.38258838653564 28.51430151808072,77.38336086273193 28.513566177802456,77.38413333892822 28.512830832397192,77.38490581512451 28.51208605426073,77.3856782913208 28.511341270865113,77.38645076751709 28.510530488025346,77.38720178604126 28.509615992924807,77.38790988922119 28.50875805732363,77.38862872123718 28.507994394490268,77.38943338394165 28.50728729434496,77.39038825035095 28.506674470385246,77.39145040512085 28.506174780521828,77.39260911941528 28.505665660113582,77.39376783370972 28.505156537248446,77.39492654800415 28.50466626846366,77.39608526229858 28.504175997400655,77.39724397659302 28.503685724059455,77.39840269088745 28.503195448440064,77.39956140518188 28.50276174118543,77.4007523059845 28.502309175192945,77.40194320678711 28.50185660725938,77.40313410758972 28.50140403738471,77.40432500839233 28.500951465568985,77.40551590919495 28.500498891812207,77.40670680999756 28.5000463161144,77.40789771080017 28.49959373847559,77.40908861160278 Code I am using to read from file: try { BufferedReader in = new BufferedReader(new FileReader("G:\\RoutePPAdvant2.txt")); String str; str = in.readLine(); while ((str = in.readLine()) != null) { System.out.println(str); } in.close(); } catch (IOException e) { System.out.println("File Read Error"); }

    Read the article

  • What is wrong in this simple Makefile

    - by Walidix
    SRC_VAR = test string for variable manipulation. TEST1_VAR = $(subset for,foo,${SRC_VAR}) all: @echo original str: ${SRC_VAR} @echo substitution: ${TEST1_VAR} This is the output: original str: test string for variable manipulation. substitution: The output should be: original str: My test string for variable manipulation. substitution: My test string foo variable manipulation.

    Read the article

  • template; Point<2, double>; Point<3, double>

    - by Oops
    Hi, I want to create my own Point struct it is only for purposes of learning C++. I have the following code: template <int dims, typename T> struct Point { T X[dims]; Point(){} Point( T X0, T X1 ) { X[0] = X0; X[1] = X1; } Point( T X0, T X1, T X2 ) { X[0] = X0; X[1] = X1; X[2] = X2; } Point<dims, int> toint() { //how to distinguish between 2D and 3D ??? Point<dims, int> ret = Point<dims, int>( (int)X[0], (int)X[1]); return ret; } std::string str(){ //how to distinguish between 2D and 3D ??? std::stringstream s; s << "{ X0: " << X[0] << " | X1: " << X[1] << " }"; return s.str(); } }; int main(void) { Point<2, double> p2d = Point<2, double>( 12.3, 45.6 ); Point<3, double> p3d = Point<3, double>( 12.3, 45.6, 78.9 ); Point<2, int> p2i = p2d.toint(); //OK Point<3, int> p3i = p3d.toint(); //m??? std::cout << p2d.str() << std::endl; //OK std::cout << p3d.str() << std::endl; //m??? std::cout << p2i.str() << std::endl; //m??? std::cout << p3i.str() << std::endl; //m??? char c; std::cin >> c; return 0; } of couse until now the output is not what I want. my questions is: how to take care of the dimensions of the Point (2D or 3D) in member functions of the Point? many thanks in advance Oops

    Read the article

  • how to convert char * to uchar16 in JNI C++

    - by Sagar Hatekar
    Hello, here's what I am trying to do: typedef uint16_t uchar16_t; uchar16_t buf[32]; // buf will contain timezone information like GMT-6, Eastern Daylight Time, etc char * str = "Test"; for (int i = 0; i <= strlen(str); i++) buf[i] = str[i]; I guess that's not correct since uchar16_t would contain 2 bytes and str contains 1 byte. What is it that I am supposed to do ?

    Read the article

  • Do word boundaries work on symbol characters?

    - by Shawn31313
    I'm trying to implement word boundaries in my emoticons feature for a chat. But for some reason I can't seem to get the word boundaries to work. I am new to regex. So when I do: var reg = /\b\Hi\b/gi; var str = 'HiHiHi Hi HiHiHi Hi'; alert(str.replace(reg, '')); This happens: Jsfiddle It actually works fine, and does remove those 2 Hi's that are standing alone. But when I change the reg to an escaped smiley and then change the string: var reg = /\b\:\)\b/gi; var str = 'HiHi:) :) HiHiHi :)'; alert(str.replace(reg, '')); This happens: Jsfiddle It just doesn't work. The string stays the same. Is it that word boundaries can't be used on symbols? If so, how does Facebook do it on their chats?

    Read the article

  • How to evaluate the string in ruby if the string contains ruby command?

    - by Arun
    In my case, I was storing the sql query in my database as text. I am showing you one record which is present in my database Query.all :id => 1, :sql => "select * from user where id = #{params[:id]}" str = Query.first Now 'str' has value "select * from user where id = #{params[:id]}" Here, I want to parsed the string like If my params[:id] is 1 then "select * from user where id = 1" I used eval(str). Is this correct?

    Read the article

  • How string accepting interface should look like?

    - by ybungalobill
    Hello, This is a follow up of this question. Suppose I write a C++ interface that accepts or returns a const string. I can use a const char* zero-terminated string: void f(const char* str); // (1) The other way would be to use an std::string: void f(const string& str); // (2) It's also possible to write an overload and accept both: void f(const char* str); // (3) void f(const string& str); Or even a template in conjunction with boost string algorithms: template<class Range> void f(const Range& str); // (4) My thoughts are: (1) is not C++ish and may be less efficient when subsequent operations may need to know the string length. (2) is bad because now f("long very long C string"); invokes a construction of std::string which involves a heap allocation. If f uses that string just to pass it to some low-level interface that expects a C-string (like fopen) then it is just a waste of resources. (3) causes code duplication. Although one f can call the other depending on what is the most efficient implementation. However we can't overload based on return type, like in case of std::exception::what() that returns a const char*. (4) doesn't work with separate compilation and may cause even larger code bloat. Choosing between (1) and (2) based on what's needed by the implementation is, well, leaking an implementation detail to the interface. The question is: what is the preffered way? Is there any single guideline I can follow? What's your experience?

    Read the article

  • printing out dictionnaires

    - by kyril
    I have a rather specific question: I want to print out characters at a specific place using the \033[ syntax. This is what the code below should do: (the dict cells has the same keys as coords but with either '*' or '-' as value.) coords = {'x'+str(x)+'y'+str(y) : (x,y) for x,y, in itertools.product(range(60), range(20))} for key, value in coords.items(): char = cells[key] x,y = value HORIZ=str(x) VERT=str(y) char = str(char) print('\033['+VERT+';'+HORIZ+'f'+char) However, I noticed that if I put this into a infinite while loop, it does not always prints the same characters at the same position. There are only slight changes, but it deletes some and puts them back in after some loops. I already tried it with lists, and there it seems to behave just fine, so I tend to think it has something todo with the dict, but I can not figure out what it could be. You can see the Problem in a console here: SharedConsole.I am happy for every tip on this matter. On a related topic: After the printing, some changes should be made at the values of the cells dict, but for reason unknown to me, the only the first two rules are executed and the rest is ignored. The rules should test how many neighbours (which is in population) are around the cell and apply the according rule. In my implemention of this I have some kind of weird tumor growth (which should not happen, as if there more than three around they should the cell should die) (see FreakingTumor): if cells_copy [coord] == '-': if population == 3: cells [coord] = '*' if cells_copy [coord] == '*': if population > 3: cells [coord] = '-' elif population <= 1: cells [coord] = '-' elif population == 2 or 3: cells [coord] = '*' I checked the population variable several times, so I am quite sure that is not the matter. I am sorry for the slow consoles. Thanks in advance! Kyril

    Read the article

  • toupper/tolower + locale (german)

    - by Oops
    Hi, how to convert a string (wstring) from lowercase to uppercase characters and vice versa? I searched the net and found there is a STL-function std::transform. But until now I hav'nt figured out how to give the right locale-object for example "Germany_german" to the function. Who can help please? my code looks like: wstring strin = L"ABCÄÖÜabcäöü"; wstring str = strin; locale loc( "Germany_german" ); // ??? how to apply this ??? std::transform( str.begin(), str.end(), str.begin(), (int(*)(int)tolower ); //result: "abcäöüabcäöü" The characters ÄÖÜ and äöü (it's like Ae, Oe, Ue) will not be converted correctly. P.S.: I don't prefer a big switch sweat and also I know BOOST is capable of everything, i would prefer a STL solution. thanks in advance Oops

    Read the article

  • Compilation Error related

    - by aparna
    Given: 11. public static void test(String str) { 12. int check = 4; 13. if (check = str.length()) { 14. System.out.print(str.charAt(check -= 1) +", "); 15. } else { 16. System.out.print(str.charAt(0) + ", "); 17. } 18. } and the invocation: 21. test("four"); 22. test("tee"); 23. test("to"); What is the result? A. r, t, t, B. r, e, o, C. Compilation fails. D. An exception is thrown at runtime. Answer: C Can you explain why the compilation fails please?

    Read the article

  • Beginner C++ Question

    - by Donal Rafferty
    I have followed the code example here toupper c++ example And implemented it in my own code as follows void CharString::MakeUpper() { char* str[strlen(m_pString)]; int i=0; str[strlen(m_pString)]=m_pString; char* c; while (str[i]) { c=str[i]; putchar (toupper(c)); i++; } } But this gives me the following compiler error CharString.cpp: In member function 'void CharString::MakeUpper()': CharString.cpp:276: error: invalid conversion from 'char*' to 'int' CharString.cpp:276: error: initializing argument 1of 'int toupper(int)' CharString.cpp: In member function 'void CharString::MakeLower()': This is line 276 putchar (toupper(c)); I understand that toupper is looking for int as a parameter and returns an int also, is that the problem? If so how does the example work?

    Read the article

  • C++ error - returning a char array

    - by Yosy
    Consider the following code: char CeaserCrypt(char str[256],int key) { char encrypted[256],encryptedChar; int currentAsci; encrypted[0] = '\0'; for(int i = 0; i < strlen(str); i++) { currentAsci = (int)str[i]; encryptedChar = (char)(currentAsci+key); encrypted[i] = encryptedChar; } return encrypted; } Visual Studio 2010 gives an error because the function returns an array. What should I do? My friend told me to change the signature to void CeaserCrypt(char str[256], char encrypted[256], int key). But I don't think that is correct. How can I get rid of the compile error?

    Read the article

  • How to insert result of mysql_real_escape_string() into oracle database?

    - by Prat
    For inserting special characters in data like (,')etc., I am using musql_real_escape_string() function & it's working fine. Now I want to use same variable while inserting values in Oracle. $str = 'N.G.Palace\'s Building', 'xyzcity', '12345678','India','100001',12 Here $str is result of mysql_real_escape_string(). so it escapes special character. Now my code for oracle is like this-: $qry ="INSERT INTO Ora_table(ship_to_street, ship_to_city,ship_to_country, ship_to_telephone, order_id, record_no) VALUES(".$str); So my doubt is Oracle is not accepting values return by mysql_real_escape_string i.e. Palace\'s (like this as this mysql function attach \ before 'single quote)? So can anybody tell me ho9w can I use that variable $str to insert data into Oracle? Also I tried like this also-: "q"."'"."c".$str."c"."'" can we use this for multiple values like in my case...though still I am unable to inser data in oracle? plz help.

    Read the article

  • Exercise 7.9 in "How to Think Like a Computer Scientist (python)" measuring occurrences of a character in a string

    - by Abie
    The question is how to write a program that measures how many times a character appears in a string in a generalizable way in python. The code that I wrote: def countLetters(str, ch): count=0 index=0 for ch in str: if ch==str[index]: count=count+1 index=index+1 print count when I use this function, it measures the length of the string instead of how many times the character occurs in the string. What did I do wrong? What is the right way to write this code?

    Read the article

  • Discard unprintable characters returned in server's XML response

    - by Penang
    While trying to use the Bing API to search, I am getting characters that are not printable and do not seem to hold any extra information. The goal is to save the XML (UTF-8) response as a text file to be parsed later. My code currently looks something like this: URL url = new URL(queryURL); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); BufferedWriter out = new BufferedWriter(new FileWriter(query+"-"+saveResultAs)); String str = in.readLine(); out.write(str); in.close(); out.close(); When I send the contents of 'str' to console it looks something like this: and here's a what the newly created local XML file looks like: What should I be doing to convert the UTF-8 text so that str does not have the extra characters?

    Read the article

  • regex in python, can this be improved upon?

    - by tipu
    I have this piece of code that finds words that begin with @ or #, p = re.findall(r'@\w+|#\w+', str) Now what irks me about this is repeating \w+. I am sure there is a way to do something like p = re.findall(r'(@|#)\w+', str) That will produce the same result but it doesn't, it instead returns only # and @. How can that regex be changed so that I am not repeating the \w+? This code comes close, p = re.findall(r'((@|#)\w+)', str) But it returns [('@many', '@'), ('@this', '@'), ('#tweet', '#')] (notice the extra '@', '@', and '#'.

    Read the article

  • NSDecimalNumber leaks memory if not used with AutoRelease pool?

    - by bioffe
    NSString* str = [[NSString alloc] initWithString:@"0.05"]; NSDecimalNumber* num = [[NSDecimalNumber alloc] initWithString:str]; NSLog(@" %@", num); [str release]; [num release]; leaks memory *** __NSAutoreleaseNoPool(): Object 0x707990 of class NSCFString autoreleased with no pool in place - just leaking Can someone suggest a workaround ?

    Read the article

  • Python 3: list atributes within a class object

    - by MadSc13ntist
    is there a way that if the following class is created; I can grab a list of attributes that exist. (this class is just an bland example, it is not my task at hand) class new_class(): def __init__(self, number): self.multi = int(number) * 2 self.str = str(number) a = new_class(2) print(', '.join(a.SOMETHING)) * the attempt is that "multi, str" will print. the point here is that if a class object has attributes added at different parts of a script that I can grab a quick listing of the attributes which are defined.

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >