Search Results

Search found 15239 results on 610 pages for 'array population'.

Page 134/610 | < Previous Page | 130 131 132 133 134 135 136 137 138 139 140 141  | Next Page >

  • How do I split ONE array to two separate arrays based on magnitude size and a threshold?

    - by youhaveaBigego
    I have an array which has BIG numbers and small numbers in it. I got it from after running a log from WireShark. It is the total number of Bytes of TCP traffic. But Wireshark does not discriminate(it would actually try, and hence it will tell you the traffic stats of ALL types of traffic, but since This is how the Array look like : @Array=qw(10912980 10924534 10913356 10910304 10920426 10900658 10911266 10912088 10928972 10914718 10920770 10897774 10934258 10882186 10874126 8531 8217 3876 8147 8019 68157 3432 3350 3338 3280 3280 7845 7869 3072 3002 2828 8397 1328 1280 1240 1194 1193 1192 1194 6440 1148 1218 4236 1161 1100 1102 1148 1172 6305 1010 5437 3534 4623 4669 3617 4234 959 1121 1121 1075 3122 3076 1020 3030 628 2938 2938 1611 1611 1541 1541 1541 1541 1541 1541 1541 1541 1541 1541 1541 1541 583 370 178) When you look at these this array carefully, one thing is obvious to the human eye. There are really BIG numbers and small numbers. (Basically what I am saying is, there is the 1% class and low income class, no middle class). I want to split the array to two different arrays. That would require me to set a threshold. Array 1 should be ONLY the BIG numbers (10924534-10874126), and array 2 should be the smaller numbers (68157-178). Btw, the array is not sorted. User will NOT input the threshold, and hence should be determined smartly.

    Read the article

  • int array doesnt get char values

    - by user1780004
    I am absolutely brand new at programming and im not sure how to explain what im doing here. The whole purpose of this piece is to enter values and then print them out in the same order. Now I wanna quit from entering values when pressing 'q' and so I have to scanf for chars but when I assign them back to the int array the values are not the same. Hope that makes any sense to you but in any case heres my code: #include <stdio.h> #include <stdlib.h> #define SIZE 5000 define flush fflush(stdin) main() { int input[SIZE] = {0},i = 0; int counter = 0; char inputs, quit; do { system("cls"); printf("Input number ('q' to quit and display numbers entered): "); flush; scanf("%c",&inputs); flush; if (inputs == 'q') quit = 'q'; else { input[i] = inputs; counter++; i++; } } while (i < SIZE && quit != 'q'); for(i = 0; i < counter; i++){ printf("%i.%i\n", i + 1, input[i]); } system("pause"); } Ive been trying to do this on my own btw and also researched some information online regarding chars but couldnt find anything that would help me. Thanks a lot in advance.

    Read the article

  • Sort the $_POST variables

    - by Jerry
    Hello guys Might be an easy for you guys. I am trying to sort the $_POST variables that were sent by a form and update the sorted result in mysql. I am not sure how to do it and appreciate it anyone can help me about it. My main.php //I have a loop here. (omitted) //$k will be increased by 1 every time the loop starts, so I will know the total times of the loops //the form will be submitted to update.php echo "<input type='hidden' name='pickTotal' value='".$k."' />"; echo "<input type='hidden' id='point' name='earnedPoint".$k."' value='".$point."' />"; echo "<input type='hidden' id='users' name='userName".$k."' value='".$userPick['user']."' />"; //loop ends My update.php if(isset($_POST['submit'])){ $pickTotal=$_POST['pickTotal']; //get the total loop for ($p=0;$p<=$pickTotal;$p++){ $userToBeUpdated=$_POST['userName'.$p]; $userPoint=$_POST['earnedPoint'.$p]; //sort the $userPoint here. //I need to find out who got the most points //and list user's place. 1st, 2nd, 3rd...etc. //update my mysql } Thanks for any helps.

    Read the article

  • PHP Array to CSV

    - by JohnnyFaldo
    I'm trying to convert an array of products into a CSV file, but it doesn't seem to be going to plan. The CSV file is one long line, here is my code: for($i=0;$i<count($prods);$i++) { $sql = "SELECT * FROM products WHERE id = '".$prods[$i]."'"; $result = $mysqli->query($sql); $info = $result->fetch_array(); } $header = ''; for($i=0;$i<count($info);$i++) { $row = $info[$i]; $line = ''; for($b=0;$b<count($row);$b++) { $value = $row[$b]; if ( ( !isset( $value ) ) || ( $value == "" ) ) { $value = "\t"; } else { $value = str_replace( '"' , '""' , $value ); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim( $line ) . "\n"; } $data = str_replace( "\r" , "" , $data ); if ( $data == "" ) { $data = "\n(0) Records Found!\n"; } header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=your_desired_name.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$data"; Also, the header doesn't force a download. I've been copy and pasting the output and saving as .csv

    Read the article

  • Java loop to collect the second and third elements every three in an array

    - by mhollander38
    I have a file with data in the form timestamp, coordinate, coordinate, seperated by spaces, as here; 14:25:01.215 370.0 333.0 I need to loop through and add the coordinates only to an array. The data from the file is read in and put into as String[] called info, from split(" "). I have two problems, I think the end of the file has a extra " " which I need to lose appropriately and I also want confirmation/suggestions of my loop, at the moment I am getting sporadic out of bounds exceptions. My loop is as follows; String[] info; info = dataHolder.split(" "); ArrayList<String> coOrds1 = new ArrayList<String>(); for (int counter = 0; counter < info.length; counter = counter+3) { coOrds1.add(info[counter+1]); coOrds1.add(info[counter+2]); } Help and suggestions appreciated. The text file is here but the class receives in a UDP packet from another class so I am unsure if this potentially adds " " at the end or not.

    Read the article

  • 3x3 array = 10 numbers

    - by user1708505
    i have this code #include <math.h> #include <stdio.h> const int n = 3; const int s = 3; int getm(int mat[n][s]); int printm(int mat[n][s]); int main() { int m[n][s]; getm(m); printm(m); return 0; } int getm(int mat[n][s]) { for(int x = 0;x < n;x++) { for (int y = 0;y<s;y++) { scanf("%i ", &mat[x][y]); } } return 0; } int printm(int mat[n][s]) { for(int x = 0;x<n;x++) { for(int y = 0;y<s;y++) { printf("%i ", mat[x][y]); if(y==(s-1)) { printf("\n"); } } } } which shoud ask for 9 numbers to make a 3x3 matrix array, but it actually asks for 10 numbers, printm is working well - printing only 9 numbers. Where is error?

    Read the article

  • [cakephp] problem with find query

    - by luk4s
    Hi I have a problem with find query: $userInProjects = $this->Timesheet->RegularPost->UserInProject->find('all', array('conditions' => array('UserInProject.user_id' => $id))); The result array: Array ( [0] => Array ( [UserInProject] => Array ( [id] => 11 [project_id] => 3 [position_id] => 1 [user_id] => 15 ) [Project] => Array ( [id] => 3 [short_name] => proj1 [full_name] => project 1 [start_date] => 2010-01-01 [end_date] => 2010-05-01 [agreement_number] => 12/34U/23 [active] => 1 [user_id] => 1 ) [Position] => Array ( [id] => 1 [name] => some_name ) [User] => Array ( [id] => 15 [username] => foo [first_name] => [last_name] => [email] => [email protected] [active] => 1 [created] => [modified] => ) [RegularPost] => Array ( [0] => Array ( [id] => 792 [date] => 2010-01-01 [size] => 0.20000 [users_in_project_id] => 11 ) [1] => Array ( [id] => 793 [date] => 2010-02-01 [size] => 0.20000 [users_in_project_id] => 11 ) ( and many more ...) ) ) [1] => Array ( [UserInProject] => Array ( [id] => 20 [project_id] => 3 [position_id] => 2 [user_id] => 15 ) [Project] => Array ( [id] => 3 [short_name] => proj1 [full_name] => project 1 [start_date] => 2010-01-01 [end_date] => 2010-05-01 [agreement_number] => 12/34U/23 [active] => 1 [user_id] => 1 ) [Position] => Array ( [id] => 2 [name] => some_name2 ) [User] => Array ( [id] => 15 [username] => foo [first_name] => [last_name] => [email] => [email protected] [active] => 1 [created] => [modified] => ) [RegularPost] => Array ( [0] => Array ( [id] => 836 [date] => 2010-01-01 [size] => 0.2 [users_in_project_id] => 20 ) [1] => Array ( [id] => 837 [date] => 2010-02-01 [size] => 0.3 [users_in_project_id] => 20 ) [2] => Array ( [id] => 838 [date] => 2010-03-01 [size] => 0.3 [users_in_project_id] => 20 ) ( and many more ...) ) ) ) What I want to achive is the array like above but RegularPost with [date] = 2010-02-01 only. Is there any way to pass the date '2010-02-01' to the RegularPost in this query? This query doesn't work: $userInProjects = $this->Timesheet->RegularPost->UserInProject->find('all', array('conditions' => array('UserInProject.user_id' => $id, 'RegularPost.date' => '2010-02-01'))); 1054: Unknown column 'RegularPost.date' in 'where clause' Please help. :)

    Read the article

  • deleting an array that stores pointers to some objects

    - by memC
    hi, I am storing pointers to elements of a vec_A in an array A* a_ptrs[3] . Assume that vec_A will not be resized. So, a_ptrs[i] will point to the correct element. My question is: Suppose A* a_ptrs[3] is declared in a class B. Since it is not created using 'new' I am guessing I don't need to delete it in the destructor. Am I right?? class A { public: int getNumber(); A(int val); ~A(){}; private: int num; }; A::A(int val){ num = val; }; int A::getNumber(){ return num; }; int main(){ int i =0; int num; std::vector<A> vec_A; for ( i = 0; i < 10; i++){ vec_A.push_back(A(i)); } A* a_ptrs[3]; a_ptrs[0] = &vec_A[0]; a_ptrs[1] = &vec_A[3]; a_ptrs[2] = &vec_A[5]; for (i = 0; i<3; i++){ std::cout<<"\n: a_ptrs[i].getNumber() = "<<a_ptrs[i]->getNumber(); } std::cout << "\nPress RETURN to continue..."; std::cin.get(); return 0; }

    Read the article

  • CoffeeScript 2 Dimensional Array Usage

    - by Chris
    I feel like I'm missing something with CoffeeScript and 2 dimensional arrays. I'm simply attempting to make a grid of spaces (think checkers). After some searching and a discovery with the arrays.map function, I came up with this: @spaces = [0...20].map (x)-> [0...20].map (y) -> new Elements.Space() And this seems to work great, I have a nice 2 dimensional array with my Space object created in each. But now I want to send the created space constructor the x,y location. Because I'm two layers deep, I lost the x variable when I entered the map function for y. Ideally I would want to do something like: @spaces = [0...20].map (x)-> [0...20].map (y) -> new Elements.Space(x, y) or something that feels more natural to me like: for row in rows for column in row @spaces[row][column] = new Elements.Space(row, column) I'm really open to any better way of doing this. I know how I would do it in standard JavaScript, but really would like to learn how to do it in CoffeeScript.

    Read the article

  • PHP the SELECT FROM WHERE col IN no working using array

    - by Sam Ram San
    I'm trying to pull some data from MySQL using an Array that was fetch from a first query. Everything's fine all the way to the implode after that, it's been a headache for me. Can someone help me? <?php $var = 'somedata'; include("config/conect.php"); $zip="SELECT * FROM table WHERE firstcol LIKE '%$var%' ORDER BY seconcol"; $results = $connetction->query($zip); while ($row = $results->fetch_array()){ $mycode[]=$row['zip']; } array_pop($mycode); $mycode = implode(', ',$mycode); //print_r ($mycode); echo '<br /><br /><br />'; $usr="SELECT * FROM reg_temp WHERE zip IN('".join("','", $mycode)."')"; $results = $asies->query($usr); while ($row = $results-> fetch_arra()) { $name = $row['name']; echo $name; } ?>

    Read the article

  • Not getting an array as result (calling a webservice by AJAX-JSON)

    - by Pasargad
    I'm trying to get the result of my web service as an array and then loop over the result to fetch all of the data; what I have done so far: In my web service when I return the result I use return json_encode($newFiles); and the result is as following: "[{\"path\":\"c:\\\\my_images\\\\123.jpg\",\"ID\":\"123\",\"FName\":\"John\",\"LName\":\"Brown\",\"dept\":\"Hr\"}]" tehn in my Web application I'm calling the rest web service by the following code in the RestService class: public function getNewImages($time) { $url = $this->rest_url['MyService'] . "?action=getAllNewPhotos&accessKey=" . $this->rest_key['MyService'] . "&lastcheck=" . $time; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); if ($data) { return json_decode($data); } else { return null; } } and then in my controller I have the following code: public function getNewImgs($time="2011-11-03 14:35:08") { $newImgs = $this->restservice->getNewImages($time); echo json_encode$newImgs; } and I'm calling this `enter code here`controller method by AJAX: $("#searchNewImgManually").click(function(e) { e.preventDefault(); $.ajax({ type: "POST", async: true, datatype: "json", url: "<?PHP echo base_url("myProjectController/getNewImgs"); ?>", success: function(imgsResults) { alert(imgsResults[0]); } }); }); but instead of giving me the first object it is just giving me quotation mark (the first charachter of the result) " Why is that? I'm passing in JSON format and in AJAX I mentioned datatype as "JSON" ! Please let me know if you need more clarification! Thanks :)

    Read the article

  • array multiplication task

    - by toby
    I am tying to get around how you will multiply the values in 2 arrays (as an input) to get an output. The problem I have is the how to increment the loops to achieve the task shown below #include <iostream> using namespace std; main () { int* filter1, *signal,fsize1=0,fsize2=0,i=0; cout<<" enter size of filter and signal"<<endl; cin>> fsize1 >> fsize2; filter1= new int [fsize1]; signal= new int [fsize2]; cout<<" enter filter values"<<endl; for (i=0;i<fsize1;i++) cin>>filter1[i]; cout<<" enter signal values"<<endl; for (i=0;i<fsize2;i++) cin>>signal[i]; /* the two arrays should be filled by users but use the arrays below for test int array1[6]={2,4,6,7,8,9}; int array2[3]={1,2,3}; The output array should be array3[9]={1*2,(1*4+2*2),(1*6+2*4+3*2),........,(1*9+2*8+3*7),(2*9+3*8),3*9} */ return 0; } This is part of a bigger task concerning filter of a sampled signal but it is this multiplication that i cant get done.

    Read the article

  • Working with a string as an array of characters

    - by Malfunction
    I'm having some trouble with a string represented as an array of characters. What I'd like to do, as I would do in java, is the following: while (i < chars.length) { char ch = chars[i]; if ((WORD_CHARS.indexOf(ch) >= 0) == punctuation) { String token = buffer.toString(); if (token.length() > 0) { parts.add(token); } buffer = new StringBuffer(); } buffer.append(ch); i++; } What I'm doing is something like this: while(i < strlen(chars)) { char ch = chars[i]; if(([WORD_CHARS rangeOfString:ch] >= 0) == punctuation) { NSString *token = buffer.toString(); if([token length] > 0) { [parts addObject:token]; } buffer = [NSMutableString string]; } [buffer append(ch)]; i++; } I'm not sure how I'm supposed to convert String token = buffer.toString(); to objective c, where buffer is an NSMutableString. Also, how do I check this if condition in objective c? if ((WORD_CHARS.indexOf(ch) >= 0) == punctuation) WORD_CHARS is an NSString. I'm also having trouble with appending ch to buffer. Any help is greatly appreciated.

    Read the article

  • What are some ways to accomplish a dynamic array?

    - by Ted
    I'm going to start working on a new game and one of the things I'd like to accomplish is a dynamic array sort of system that would hold map data. The game will be top-down 2d and made with XNA 4.0 and C#. You will begin in a randomized area which will essentially be tile based. As such a 2 dimensional array would be one way to accomplish this by holding numerical values which would correspond to a list of textures and that would be how it would draw this randomly created map. The problem is I would kind of only like to create the area around where you start and they could venture in which ever direction they wanted to. This would mean I'd have to populate the map array with more randomized data in the direction they go. I could make a really large array and use the center of it and the rest would be in anticipation of new content to be made, but that just seems very inefficient. I suppose when they start a new game I could have a one time map creation process that would go through and create a large randomly generated map array, but holding all of in memory at all times seems also inefficient. Perhaps if there was a way that I'd only hold parts of that map data in memory at one time and somehow not hold the rest in memory. In the end I only need to have a chunk of the map somewhat close to them in memory so perhaps some of you might have suggestions on good ways to approach this kind of randomized map and dynamic array problem. It wouldn't need to be a dynamic array type of thing if I made it so that it pulled in map data nearby that is needed and then once off the screen and not needed it could somehow get rid of that memory that way I wouldn't have a huge array taking up a bunch of memory.

    Read the article

  • Calculations coming out to 0.0?

    - by Nick Gibson
    A simple percentage calculation. It wont return a value except 0.0 and I think once or twice it returned 100.0%. Other than that it won't do a thing. I have tried playing with the code in several different ways and it just wont work. for (int loop = 1; loop < loopCount; loop++) { aa = r.nextInt(10+1); abc = (int) aa; String[] userAnswer = new String[x]; int totalQues = (correctAnswer + wrongAnswer), actualQues = (totalQues - 1); if(abc < x) { userAnswer[abc] = JOptionPane.showInputDialog(null,"Question "+quesNum+"\n\n"+questions[abc]+"\n\nA: "+a[abc]+"\nB: "+b[abc]+"\nC: "+c[abc]+"\nD: "+d[abc]+"\nCorrect Answers: "+correctAnswer+"\nWrong Answers: "+wrongAnswer+"\nTotal Questions: "+totalQues); if(userAnswer[abc].equals(answers[abc])) { correctAnswer++; } else { wrongAnswer++; }//else if(actualQues == x); { score = (correctAnswer / actualQues) * 100; JOptionPane.showMessageDialog(null,"The test is finished."); JOptionPane.showMessageDialog(null,"You scored "+score+"%"); }//if }//if }//for

    Read the article

  • Writing a recursive sorting algorithm of an array of integers

    - by 12345
    I am trying to write a recursive sorting algorithm for an array of integers. The following codes prints to the console: 3, 5, 2, 1, 1, 2, 6, 7, 8, 10, 20 The output should be sorted but somehow "it doesn't work". public static void main(String[] args) { int[] unsortedList = {20, 3, 1, 2, 1, 2, 6, 8, 10, 5, 7}; duplexSelectionSort(unsortedList, 0, unsortedList.length-1); for (int i = 0; i < unsortedList.length; i++) { System.out.println(unsortedList[i]); } } public static void duplexSelectionSort( int[] unsortedNumbers, int startIndex, int stopIndex) { int minimumIndex = 0; int maximumIndex = 0; if (startIndex < stopIndex) { int index = 0; while (index <= stopIndex) { if (unsortedNumbers[index] < unsortedNumbers[minimumIndex]) { minimumIndex = index; } if (unsortedNumbers[index] > unsortedNumbers[maximumIndex]) { maximumIndex = index; } index++; } swapEdges(unsortedNumbers, startIndex, stopIndex, minimumIndex, maximumIndex); duplexSelectionSort(unsortedNumbers, startIndex + 1, stopIndex - 1); } } public static void swapEdges( int[] listOfIntegers, int startIndex, int stopIndex, int minimumIndex, int maximumIndex) { if ((minimumIndex == stopIndex) && (maximumIndex == startIndex)) { swap(listOfIntegers, startIndex, stopIndex); } else { if (maximumIndex == startIndex) { swap(listOfIntegers, maximumIndex, stopIndex); swap(listOfIntegers, minimumIndex, startIndex); } else { swap(listOfIntegers, minimumIndex, startIndex); swap(listOfIntegers, maximumIndex, stopIndex); } } } public static void swap(int[] listOfIntegers, int index1, int index2) { int savedElementAtIndex1 = listOfIntegers[index1]; listOfIntegers[index1] = listOfIntegers[index2]; listOfIntegers[index2] = savedElementAtIndex1; }

    Read the article

  • PHP multi-post issue.

    - by user1887185
    When I have two or more comments on a post, it show the post again and the next comment underneath it. How do I make it so it shows only the post once and the comments underneath it if there are multiple comments? $sql_posts = mysql_query("SELECT * FROM posts ORDER BY post_date DESC "); $postDisplayList = ""; while($row = mysql_fetch_array($sql_posts)){ $postid = $row["id"]; $uid = $row["user_id"]; $the_post = $row["post"]; $post_date = $row["post_date"]; $sql_mem_data = mysql_query("SELECT id, username, firstname, lastname FROM users WHERE id='$uid' LIMIT 1"); while($row = mysql_fetch_array($sql_mem_data)){ $uid = $row["id"]; $username = $row["username"]; $firstname = $row["firstname"]; $lastname = $row["lastname"]; } $sql_com_data = mysql_query("SELECT * FROM comments WHERE post_id='$postid' "); while($row = mysql_fetch_assoc($sql_com_data)){ $uid1 = $row["user_id"]; $comment = $row["comment"]; $whencomment = $row["comment_date"]; $sql_com_data_user = mysql_query("SELECT * FROM users WHERE id='$uid1' "); while($row = mysql_fetch_array($sql_com_data_user)){ $username1 = $row["username"]; $firstname1 = $row["firstname"]; $lastname1 = $row["lastname"]; } $postDisplayList .= ' <table width="100%" align="center" cellpadding="6" style="background-color:#F2F2F2; "> <tr> <td width="93%" bgcolor="#F2F2F2" style="line-height:1.5em;" valign="top"> <span class="liteGreyColor textsize9"> ' . $post_date . ' <a href="profile.php?id=' . $uid . '"><strong>' . $username . '</strong></a></span><br /> <span class="textsize14"> ' . $the_post . '</span> </td> </tr> <tr> <td width="93%" bgcolor="#F2F2F2" style="line-height:1.5em;" valign="top"> <span class="liteGreyColor textsize9"> ' . $whencomment . ' <a href="profile.php?id=' . $uid1 . '"><strong>' . $username1 . '</strong></a></span><br /> <span class="textsize14"> ' . $comment . '</span> </td> </tr> </table>';

    Read the article

  • Assigning address to array from heap

    - by Schaltfehler
    I want to save the state of my structs as a binary file and load them again. My structs look like this: typedef struct { uint8_t pointerLength; uint8_t *pointer; uint8_t NumBla; uinT16 Bla[MAX_NUM_Bla]; ... } BAR_STRUCT, *BAR; typedef struct { int numBar; BAR bars[MAX_NUM_BAR]; } FOO_STRUCT, *FOO; Saving is no problem, but restoring the state. Iam at the point where the bytestring from the file is on the heap and a pointer is pointing to the first adress of this string. And I do as follows: const void* dataPointer //points to adress in heap unsigned char* bytePointer = (unsigned char*)dataPointer; FOO foo = (FOO_STRUCT*)bytePointer; bytePointer += sizeof(FOO_STRUCT); for (int i=0; i < MAX_NUM_BAR; i++) { foo->bars[i] = (BAR_STRUCT*)bytePointer; } The last assignment doesn't work and I get an EXC_BAD_ACCESS. Because bars is an array of pointers i need to correct the adresses of each element is pointing to. Because they are not valid anymore. So I try to assign the adress of the object I saved in the bytesteam to foo-bars[i]; But I can not change foo-bars[i] at all. Accessing works but but assigning a new adress doesn't. I wonder why.

    Read the article

  • Adding different objects to array, but only one object repeating

    - by Carpetfizz
    I have a small piece of PHP code that goes through valid values and fetches information about them. It then pushes it to an array. For some reason, I'm only getting the last item of $row, repeated several times. When I try to print_r at #1 in the code, the expected values are outputted. However, at the end of the loop, or outside of it, when I try to print_r($ipArray), I'm only getting the last value repeated multiple times. Any help would be much appreciated! while($row = mysqli_fetch_array($getIpQuery, MYSQLI_NUM)){ for($x=0;$x<count($row);$x++) { $getIpInfo = mysqli_query($dbcon, "SELECT * FROM ipInfo WHERE address='$row[$x]'"); $retrievedInfo = mysqli_fetch_array($getIpInfo, MYSQLI_NUM); $ipInfo->ipAddress = $retrievedInfo[0]; $ipInfo->portNum = $retrievedInfo[1]; print_r($ipInfo); //#1: Works perfectly fine. array_push($ipArray,$ipInfo); } } print_r($ipArray); //this is where I'm getting an output of only the last element of `$row`. Thanks! ~Carpetfizz

    Read the article

  • Comparing C++ input with array values

    - by Security_Gate
    Hey everyone, Over the last couple months I've still been slowly but surely trudging through C++, and I've run into a snag that I've been meaning to figure out. I've tried asking/reading/searching, but I could never find an appropriate answer. Maybe it is simply because the question is sort of difficult to ask. What I'm trying to do is at the end of my program, have the end sequence compare the input value with values within an Array. Do I have to loop a comparison sequence? Is there an easier way around this? #include <iostream> #include <string> using namespace std; int main () { string YesAnswers[5] = {"Y", "YES", "yes" "y"}; string Name; string YN; do { cout << "Enter your name: "; getline(cin, Name); cout << "Your name is "<< Name; cout <<"\nIs this correct? Y\N: "; cin >> YN; } while(YN == YesAnswers); system("Pause"); return 0; }

    Read the article

  • storing user input into string array in C

    - by Jcmoney1010
    I'm writing a program that is supposed to take in a list of names from the user, store them in an array, and then search through the list to check and see if the next name the user enters is part of the original list of names. The issue I'm having is that when I go to enter a list of names, it only saves the last name entered into the list. I've searched the web and this site for similar issues, but I can't seem to find anything that answers this issue specifically. Here is the part of code where I have problem void initialize(char names[][],const int MAX_NAMES,const int MAX_NAMELENGTH) { int i,Number_entrys; printf("How many names would you like to enter to the list?"); scanf("%d",&Number_entrys); if(Number_entrys>MAX_NAMES){ printf("Please choose a smaller entry"); }else{ for (i=0; i<Number_entrys;i++){ scanf("%s",names); } } printf("%s",names); } trying very hard to teach myself, so be gentle lol.

    Read the article

  • Looping through array values using JQuery and show them on separate lines

    - by user3192948
    I'm building a simple shopping cart where visitors can select a few items they want, click on the "Next" button, and see the confirmation list of things they just selected. I would like to have the confirmation list shown on each line for each item selected. HTML selection <div id="c_b"> <input type="checkbox" value="razor brand new razor that everyone loves, price at $.99" checked> <input type="checkbox" value="soap used soap for a nice public shower, good for your homies, price at $.99" checked> <input type="checkbox" value="manpacks ultimate choice, all in 1, price at $99"> </div> <button type='button' id='confirm'>Next</button> HTML confirmation list <div id='confirmation_list' style='display:none;'> <h2>You have selected item 1</h2> <h2>Your have selected item 2 </h2> </div> JS $(function(){ $('#confirm').click(function(){ var val = []; $(':checkbox:checked').each(function(i){ val[i] = $(this).val(); }); }); }); I ultimately want to replace the words 'Your have selected item 2' in h2s with the values selected from each check box. With the code above I'm able to collect the values of each checkbox into an array val, but having difficulty looping through and displaying them. Any advice would be appreciated.

    Read the article

< Previous Page | 130 131 132 133 134 135 136 137 138 139 140 141  | Next Page >