how do i remove an element in a c++ array when the array is predetermined?
962937
You will have to set the element in the array to null, then loop through the rest of the array, moving each up (loop element - 1) until you reach the end of the array.\n\nI have included a link to a site which shows you some great basic array manipulation. Scroll down to the section titled "Inserting" and you will find some code that shows you the moving up of items after an insert. The same thing will apply when you remove an item. Everything below the delete will then move up to take the space of the deleted item.\n\nJust remember that after all items are moved up that the last item is set to null so that you won't have to items that are the same and you have a null that can terminate a loop through the array.\n\nCheck out the link and I hope it helps! Good luck!
578465
The easiest way to do this is to count back from the end of the array.\n\nFor instance, if an array has three values, \n$item[0], $item[1] and $item[2] then you can access the last with:\n$item[-1]... an easy way to reach it!
956311
I'll tell U something that could help in the reverse task\n\nU can use one of two things\n\n1-\nby includeing <string> & < algorithm>\n\nvoid revers(char* a,int length)\n{\n     string s = a;\n     reverse(s.begin() , s.end());\n     a = s;\n}\n\n2- \nby using a loop\n\nvoid reverse(char *a,int length)\n{\n     int i=0;\n     for(i=0;i< = (length/2) ;i++)\n          a[length-i-1] = a[i];\n}
818446
It is called an ARRAY
876944
I'm not fully sure of what you're trying to do here, but if you're trying to make sub-menus you can simply put all of the cout and cin statements for each sub-menu in between the cout<<" You selected... etc."; and the break statements. If you want it in another function, you can do:\n\nint main() {\n\n   //Other lines of code...\n\n   switch (choice)\n   {\n      case 1:\n         cout<< " You selected item 1.&#92;n";\n         //Call the first menu\n         menu1();\n         break;\n      }\n   }\n\n   void menu1() {\n      //This is the first menu!\n      int choice;\n      cout<< "This is the first menu...&#92;n";\n      cout<< "Pick something!&#92;n";\n      cin>> choice;\n      //Do other stuff here\n   }\n\n\nSorry if this doesn't help; I don't know C++ very well, and if you could expand on what you want to do I could help more. If this is what you want, then it's all good!
157926
Choose the most repeated operation and determine of what its repeat is dependent on (amount of input data).\n\nFor example: for (int i=0; i<N; i++) { /* do something */ )\nHas complexety N because /* do something */ is repeated N times. Here N is supplied to the algorightm.\n\nFor example: Two nested loops on of N and another of M operations have complexity of N*M.\n\nYou can ignore constant additions and substractions if they dont depend on the amount of the input data (as the are constant).\n\nFor example if you initialize an array of 100 elements in the begining of the algorithem, you can ignore it instead of include it as 100+N for example :)
382045
Maybe you could make a method to remove certain characters from a string like string removeChars( string in, string chars )\n\nThe first param is the string you want to change and the second is the characters that you want to remove from the string. The method would use a for loop that loops through the chars string and in the for loop you would have a while loop that keeps on looping while the input string contains the character in the chars string at the index of the for loop. I don't think I said that very well, but the code might look like this:\n\nstring removeChars( string in, string chars );\n{\nfor ( int i = 0; i < chars.length(); i++ )\n{\nchar theChar = (chars.c_str())[ i ];\nint f = in.find_first_of( theChar );\nwhile ( f != -1 )\n{\nin.replace( f, 1, "" );\n}\n}\n\nreturn in;\n}\n\nThen, somewhere else in the program, you could call it like this: string cleanString = removeChars( "(in}[)]", "(){}[]" ); Then cleanString would equal "in".
241835
i guess compiler tells you that is an unreachable code... because the main function has ended before and the sentence will never be executed
1011128
Please post the snippet of code that does not work. In general, you need to check an array's length before yo uaccess its elements - it's called defensive programming, and good programmers should employ it.
554785
Dim CurrentlySelected as integer\n\n'Get the currently selected item\nCurrentlySelected = MyListbox.ListIndex\n\n'Delete the currently selected item\nMyListBox.RemoveItem(CurrentlySelected)
604143
here is a program for 10 numbers in ascending order\n\n#include <iostream.h>\n#include <conio.h>\n\nvoid main()\n{\nclrscr();\nint array[10],t;\nfor(int x=0;x<10;x++)\n{\ncout << "Enter Integer No. " << x+1 << " : " << endl;\ncin>>array[x];\n}\nfor (x=0;x<10;x++)\n{\nfor(int y=0;y<9;y++)\n{\nif(array[y]>array[y+1])\n{\nt=array[y];\narray[y]=array[y+1];\narray[y+1]=t;\n}\n}\n}\ncout << "Array in ascending order is : ";\nfor (x=0;x<10;x++)\ncout << endl << array[x];\ngetch();\n}\n\nThis program takes in the ten integers array[x] to be stored in the single-dimensional array as a screen input from the user.\nIt then sorts out these ten integers into ascending order and prints them out using the 'cout' command.
344651
Hey, email me, LBphan@gmail.com, i might be able to help you out a bit, ive got some stuff for c++ and c# if youre curious, and ill give you whatever youre looking for free of charge.  my name is andy, by the way.
448114
In C++ you should do this:
423121
are you talking about c++? i have a nice header file that i can give you.. maybe thatll help
642129
ok, here is one declaration, of many;\n\nfloat Doc(int arr[100], int NumCt)\n{\nfloat sum = 0.0;\nfor (int i = 0; i < NumCt; i++)\nsum += arr[i];\n\nif (!NumCt)\nreturn sum;\n\nreturn sum / NumCt;\n}
912485
there is no "code" for it. The compiler evaluates it at the compile time, and replaces with the actual number.\nThere is no way to write a function that would did that at run time, because at run time, there is not type information available - only addresses of variables not their sizes
374089
It has 2-bytes code, so you need to examine two consequent bytes. It is not C++ specific, it is PC-specific.