Search Results

Search found 4934 results on 198 pages for 'finding'.

Page 26/198 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • Finding character in String in Vector.

    - by SoulBeaver
    Judging from the title, I kinda did my program in a fairly complicated way. BUT! I might as well ask anyway xD This is a simple program I did in response to question 3-3 of Accelerated C++, which is an awesome book in my opinion. I created a vector: vector<string> countEm; That accepts all valid strings. Therefore, I have a vector that contains elements of strings. Next, I created a function int toLowerWords( vector<string> &vec ) { for( int loop = 0; loop < vec.size(); loop++ ) transform( vec[loop].begin(), vec[loop].end(), vec[loop].begin(), ::tolower ); that splits the input into all lowercase characters for easier counting. So far, so good. I created a third and final function to actually count the words, and that's where I'm stuck. int counter( vector<string> &vec ) { for( int loop = 0; loop < vec.size(); loop++ ) for( int secLoop = 0; secLoop < vec[loop].size(); secLoop++ ) { if( vec[loop][secLoop] == ' ' ) That just looks ridiculous. Using a two-dimensional array to call on the characters of the vector until I find a space. Ridiculous. I don't believe that this is an elegant or even viable solution. If it was a viable solution, I would then backtrack from the space and copy all characters I've found in a separate vector and count those. My question then is. How can I dissect a vector of strings into separate words so that I can actually count them? I thought about using strchr, but it didn't give me any epiphanies.

    Read the article

  • Finding Local IP via Socket Creation / getsockname

    - by BSchlinker
    I need to get the IP address of a system within C++. I followed the logic and advice of another comment on here and created a socket and then utilized getsockname to determine the IP address which the socket is bound to. However, this doesn't appear to work (code below). I'm receiving an invalid IP address (58.etc) when I should be receiving a 128.etc Any ideas? string Routes::systemIP(){ // basic setup int sockfd; char str[INET_ADDRSTRLEN]; sockaddr* sa; socklen_t* sl; struct addrinfo hints, *servinfo, *p; int rv; memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; if ((rv = getaddrinfo("4.2.2.1", "80", &hints, &servinfo)) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); return "1"; } // loop through all the results and make a socket for(p = servinfo; p != NULL; p = p->ai_next) { if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) { perror("talker: socket"); continue; } break; } if (p == NULL) { fprintf(stderr, "talker: failed to bind socket\n"); return "2"; } // get information on the local IP from the socket we created getsockname(sockfd, sa, sl); // convert the sockaddr to a sockaddr_in via casting struct sockaddr_in *sa_ipv4 = (struct sockaddr_in *)sa; // get the IP from the sockaddr_in and print it inet_ntop(AF_INET, &(sa_ipv4->sin_addr.s_addr), str, INET_ADDRSTRLEN); printf("%s\n", str); // return the IP return str; }

    Read the article

  • algorithm advice for finding maximum items within a time period

    - by darren
    Hi everyone. I have a database schema that is similar to the following: | User | Event | Date |--------|---------------|------ | 111 | Walked dog | 2009-10-1 | 222 | Walked dog | 2009-10-2 | 333 | Fed Fish | 2009-10-5 | 222 | Did Laundry | 2009-10-6 | 111 | Fed Fish | 2009-10-7 | 111 | Walked dog | 2009-10-18 | 222 | Walked dog | 2009-10-19 | 111 | Fed Fish | 2009-10-21 I would like to produce a query that returns the maximum number of times a user performs some action within a time period. For example, given a time period of 5 days, what is the maximum number of times user 111 walked the dog? The most obvious solution would be to start at some zero point and move forward each day, summing up 5 day periods along the way, then taking the maximum total out of all the 5 day windows. the approach seems incredibly costly however. I would appreciate any suggestions you may have.

    Read the article

  • Problem with finding the next word in RichTextBox

    - by paradisonoir
    As I enter a character in my RichTextBox, I want to get the next character from the its TextRange. So here is how I do it: TextPointer ptr1= RichTextBox.CaretPosition; char nextChar = GetNextChar(); while (char.IsWhiteSpace(nextChar)) { ptr1= ptr1.GetNextInsertionPosition(LogicalDirection.Forward); nextChar = GetCharacterAt(Ptr1); } then I get the ptr1 of the next character and from the TextPointer, I get the TextRange, and do my changes. So here is the problem? when the next word is spelled correctly, I have no problem, but if it's not spelled properly then ptr1 would not point to the first character of the next word (the second character), and if I use GetNextContextPosition(LogicalDirection.Forward) it would give me the first letter of the next word if it's misspelled. So depending on the spelling only one of them works? I was just wondering if you have any idea about this problem? Is there anything wrong I am doing here?

    Read the article

  • WCF with SSL- not finding localhost

    - by SteveCav
    Hi guys, I'm trying to get WCF to use SSL with ANYTHING for FIVE DAYS now. I've gone through countless walkthroughs, generated more certificates than a mail order diploma company, even tried hot fixes. After working with MS dev tools since VB1, I am now considering flipping burgers as a career option. WCF, as far as I can see, is a complete lemon. Anyway, to get to my actual question: If I run through this walkthrough: http://msdn.microsoft.com/en-us/library/ff648840.aspx I get to step 11 (adding the service reference) and get "There was an error downloading metadata from the address. Please verify that you have entered a valid address". Details of the error gives: There was an error downloading 'https://localhost/SSL6/Service.svc'. Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:443 I'm using VS2008 on Windows 7 with IIS7. I followed the walkthrough exactly (apart from step 5 which was different on IIS7- I went into "SSL Settings" for the VD), so it shows my config (yes I've used httpsGetEnabled and mexHttpsBinding). Anyone care to save my sanity and job?

    Read the article

  • Need Help finding an appropriate task asignment algoritm for a collage project involving coordinatin

    - by Trif Mircea
    Hello. I am a long time lurker here and have found over time many answers regarding jquery and web development topics so I decided to ask a question of my own. This time I have to create a c++ project for collage which should help manage the workflow of a company providing all kinds of services through in the field teams. The ideas I have so far are: client-server application; the server is a dispatcher where all the orders from clients get and the clients are mobile devices (PDAs) each team in the field having one a order from a client is a task. Each task is made up of a series of subtasks. You have a database with estimations on how long a task should take to complete you also know what tasks or subtasks each team on the field can perform based on what kind of specialists made up the team (not going to complicate the problem by adding needed materials, it is considered that if a member of a team can perform a subtask he has the stuff needed) Now knowing these factors, what would a good task assignment algorithm be? The criteria is: how many tasks can a team do, how many tasks they have in the queue, it could also be location, how far away are they from the place but I don't think I can implement that.. It needs to be efficient and also to adapt quickly is the human dispatcher manually assigns a task. Any help or leads would be really appreciated. Also I'm not 100% sure in the idea so if you have another way you would go about creating such an application please share, even if it just a quick outline. I have to write a theoretical part too so even if the ideas are far more complex that what i outlined that would be ok ; I'd write those and implement what I can.

    Read the article

  • Finding matching submatrics inside a matrix

    - by DaveO
    I have a 100x200 2D array expressed as a numpy array consisting of black (0) and white (255) cells. It is a bitmap file. I then have 2D shapes (it's easiest to think of them as letters) that are also 2D black and white cells. I know I can naively iterate through the matrix but this is going to be a 'hot' portion of my code so speed is an concern. Is there a fast way to perform this in numpy/scipy? I looked briefly at Scipy's correlate function. I am not interested in 'fuzzy matches', only exact matches. I also looked at some academic papers but they are above my head.

    Read the article

  • Finding an HTTP proxy that will intercept static resource requests

    - by pkh
    Background I develop a web application that lives on an embedded device. In order to make dev times sane, frontend development is done using apache serving static documents, with PHP proxying out to the embedded device for specifically configured dynamic resources. This requires that we keep various server-simulation scripts hanging around in source control, and it requires updating those scripts whenever we add a new dynamic resource. Problem I'd like to invert the logic: if the requested document is available in the static documents directory, serve it; otherwise, proxy the request to the embedded device. Optimally, I want a software package that will do this for me (for Windows or buildable on cygwin). I can deal with forcing apache to do it with PHP, but I'm unsure how to configure it to make it happen. I've looked at squid and privoxy, but neither of them seem to do what I want. Any ideas? I'd rather not have to roll my own.

    Read the article

  • jQuery click event on parent, but finding the child (clicked) element

    - by Mahdi
    let say I have a parent element which has so many nested child elements inside of itself: <div id="p"> <div id="c1"> <div id="c2"></div> <div id="c3"></div> </div id="c4"> <div id="c5"></div> </div> </div> I've already bind a click event on the parent: $('#p').bind('click', function() { alert($(this).attr('id')); }); Because the event is assigned to the parent element, I always see the parent id, however, I'm wondering if there is any possible way to find out which of this child elements has been clicked? I also can't assign any event to the child elements or remove the event listener from parent div.

    Read the article

  • Finding IterationID in TFS

    - by Kolchak
    Hi - we are linking Iterations within TFS to an external system for tracking projects through the entire company. In the past, we were linking using the IterationPath in a TFS Project, but the problem is that people rename these IterationPaths as the projects progress, and the link is lost. So after some research, I'm thinking of doing the linking by using the IterationID. The IterationID in the TFSWarehouse is NOT the same as the IterationID in the WorkItemTracking table, and I can't seem to find an easy way to find the IterationID of an IterationPath? Anyone got any idea how we may be able to achieve this?

    Read the article

  • Java: Finding objects in collections.

    - by Jake
    This problem occurs over and over. I have some complicated object, such as a Cat, which has many properties, such as age, favorite cat food, and so forth. A bunch of Cats are stored in a Java Collection, and I need to find all the Cats that are aged 3, or those whose favorite cat food is Whiskas. Surely, I can write a custom method that finds those Cats with a specific property, but this gets cumbersome with many properties; is there some generic way of doing this?

    Read the article

  • Finding File WIth Fixed File Size (>0) in Unix/Linux

    - by neversaint
    I have a list of file that looks like this 4 -rw-r--r-- 1 neversaint hgc0746 53 May 1 10:37 SRX016372-SRR037477.est_count 4 -rw-r--r-- 1 neversaint hgc0746 53 May 1 10:34 SRX016372-SRR037478.est_count 4 -rw-r--r-- 1 neversaint hgc0746 53 May 1 10:41 SRX016372-SRR037479.est_count 0 -rw-r--r-- 1 neversaint hgc0746 0 Apr 27 11:16 SRX003838-SRR015096.est_count 0 -rw-r--r-- 1 neversaint hgc0746 0 Apr 27 11:32 SRX004765-SRR016565.est_count What I want to do is to find files that has exactly size 53. But why this command failed? $ find . -name "*.est_count" -size 53 -print It works well though if I just want to find file of size 0 with this command: $ find . -name "*.est_count" -size 0 -print

    Read the article

  • Finding matches between multiple JavaScript Arrays

    - by Chris Barr
    I have multiple arrays with string values and I want to compare them and only keep the matching results that are identical between ALL of them. Given this example code: var arr1 = ['apple', 'orange', 'banana', 'pear', 'fish', 'pancake', 'taco', 'pizza']; var arr2 = ['taco', 'fish', 'apple', 'pizza']; var arr3 = ['banana', 'pizza', 'fish', 'apple']; I would like to to produce the following array that contains matches from all given arrays: ['apple', 'fish', 'pizza'] I know I can combine all the arrays with var newArr = arr1.concat(arr2, arr3); but that just give me an array with everything, plus the duplicates. Can this be done easily without needing the overhead of libraries such as underscore.js? (Great, and now i'm hungry too!) EDIT I suppose I should mention that there could be an unknown amount of arrays, I was just using 3 as an example.

    Read the article

  • Finding the largest subtree in a BST

    - by rakeshr
    Given a binary tree, I want to find out the largest subtree which is a BST in it. Naive approach: I have a naive approach in mind where I visit every node of the tree and pass this node to a isBST function. I will also keep track of the number of nodes in a sub-tree if it is a BST. Is there a better approach than this ?

    Read the article

  • Finding Last Fired time using a Cron Expression in Java

    - by a-sak
    Is there a way in Java to find the "Last Fired Time" from a Cron Expression. E.g. If now = 25-Apr-2010 10pm, cron expression "0 15 10 ? * *" (quartz) should return me 25-Apr-2010 10:15am I do not care if we use standard cron expressions (like Unix and Quartz) or less popular ones if they can fetch me the correct "Last Fired Time"

    Read the article

  • Finding the average of two number using classes and methods

    - by Have alook
    I want to use methods inside class. Q: find the average of two number using classes and methods. import java.util.*; class aaa { int a,b,sum,avrg; void average() { System.out.println("The average is ="+avrg); avrg=(sum/2); } } class ave { public static void main(String args[]){ aaa n=new aaa(); Scanner m=new Scanner(System.in); System.out.println("write two number"); n.a=m.nextInt(); n.b=m.nextInt(); n.average(); } }

    Read the article

  • Finding out document template type of document library

    - by blade
    Hi, When I make a document library in Sharepoint 2003 and select the document template type etc and come back to edit/administer the document library, how can I find out what document template type I selected at the time of creation? Another way of putting it: If an administrator makes a document library and selects a document template type and he/she leaves without documenting his/her settings for the document library, how could I find out what document template type he selected? Thanks

    Read the article

  • Prolog - Finding the current directory, relative directory for 'tell' predicate

    - by Bharat
    I'm having trouble trying to figure out how to get prolog to spit out a text file where I want it to. I'm currently doing a bunch of operations and then using tell('output.txt') to record the output. Now the problem is that when I do this, it creates this file in the SWI \bin\ folder. I was wondering if there's a way to make it create this file in the directory containing the actual .pl file. So even if the file was moved (and it will be), the text file gets created right where the source file is. Long story short, is there a way to get the location of the source file once the source file has been consulted? Many Thanks!

    Read the article

  • Selenium not finding LiveValidation text.

    - by McNabbToSkins
    I am using the Selenium IDE to test some of my web development. I am using the JQuery LiveValidation in my code. I have an input box with some javascript behind it that will do a regular expresson and either ouput "OK" or "Error" next to the input text box based on what the user has entered. For some reason when testing with selenium the LiveValidation will not get triggered no matter what I do and therefore I can not test it. When I do it manually it works great. Has anyone run into this problem before? Any help would be appreciated.

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >