Search Results

Search found 261 results on 11 pages for 'timothy miller'.

Page 8/11 | < Previous Page | 4 5 6 7 8 9 10 11  | Next Page >

  • Good IM/Chat solution for pasting code

    - by Matt Miller
    We've got several distributed developers working together on a couple of projects. We've been using Skype to host chats with all the developers, and it works okay except for one thing: It REALLY mangles any code we copy and paste into the chats -- especially the whitespace in Python. This question has tons of opinions about chat clients & servers, but no one has much to say about pasting in code. (http://stackoverflow.com/questions/36415/best-chat-im-tool-for-developers) Is anybody out there using a chat or im client that handles source code really well?

    Read the article

  • What comes first in Ruby's object model?

    - by Timothy
    I've been reading Metaprogramming Ruby and the object model like the chicken or egg dilemma. In Ruby 1.8, the Object class is an instance of Class. Module's superclass is Object and is an instance of Class. Class' superclass is Module, and it is an instance of Class (self-referential). Say class SomeClass; end is defined somewhere; SomeClass is an instance of Class, however its superclass is Object. Why does an instance of Class have Object as the superclass instead of nil? Also, if Object is to exist, then Class has to exist, but then Module has to exist, but for Module to exist Object has to exist. How are these classes created?

    Read the article

  • Mono Ignores Graphics.InterpolationMode?

    - by Timothy Baldridge
    I have a program that draws some vector graphics using System.Drawing and the Graphics class. The anti-aliasing works, kindof okay, but for my need I neede oversampling, so I create the starting image to be n times larger and then scale back the final image by n. On Window and .NET the resulting image looks great! However, on Mono 2.4.2.3 (Ubuntu 9.10 stock install), the intropolation is horrible. Here's how I'm scaling my images: Bitmap bmp = new Bitmap(Bmp.Width / OverSampling, Bmp.Height / OverSampling); Graphics g = Graphics.FromImage(bmp); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(Bmp, 0, 0, bmp.Width, bmp.Height); g.Dispose(); From what I can tell there is no interpolation happening at all. Any ideas?

    Read the article

  • Learn Prolog Now! DCG Practice Example

    - by Timothy
    I have been progressing through Learn Prolog Now! as self-study and am now learning about Definite Clause Grammars. I am having some difficulty with one of the Practical Session's tasks. The task reads: The formal language anb2mc2mdn consists of all strings of the following form: an unbroken block of as followed by an unbroken block of bs followed by an unbroken block of cs followed by an unbroken block of ds, such that the a and d blocks are exactly the same length, and the c and d blocks are also exactly the same length and furthermore consist of an even number of cs and ds respectively. For example, ε, abbccd, and aaabbbbccccddd all belong to anb2mc2mdn. Write a DCG that generates this language. I am able to write rules that generate andn, b2mc2m, and even anb2m and c2mndn... but I can't seem to join all these rules into anb2mc2mdn. The following are my rules that can generate andn and b2mc2m. s1 --> []. s1 --> a,s1,d. a --> [a]. d --> [d]. s2 --> []. s2 --> c,c,s2,d,d. c --> [c]. d --> [d]. Is anb2mc2mdn really a CFG, and is it possible to write a DCG using only what was taught in the lesson (no additional arguments or code, etc)? If so, can anyone offer me some guidance how I can join these so that I can solve the given task?

    Read the article

  • Reading a C/C++ data structure in C# from a byte array

    - by Chris Miller
    What would be the best way to fill a C# struct from a byte[] array where the data was from a C/C++ struct? The C struct would look something like this (my C is very rusty): typedef OldStuff { CHAR Name[8]; UInt32 User; CHAR Location[8]; UInt32 TimeStamp; UInt32 Sequence; CHAR Tracking[16]; CHAR Filler[12];} And would fill something like this: [StructLayout(LayoutKind.Explicit, Size = 56, Pack = 1)]public struct NewStuff{ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)] [FieldOffset(0)] public string Name; [MarshalAs(UnmanagedType.U4)] [FieldOffset(8)] public uint User; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)] [FieldOffset(12)] public string Location; [MarshalAs(UnmanagedType.U4)] [FieldOffset(20)] public uint TimeStamp; [MarshalAs(UnmanagedType.U4)] [FieldOffset(24)] public uint Sequence; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] [FieldOffset(28)] public string Tracking;} What is best way to copy OldStuff to NewStuff, if OldStuff was passed as byte[] array? I'm currently doing something like the following, but it feels kind of clunky. GCHandle handle;NewStuff MyStuff;int BufferSize = Marshal.SizeOf(typeof(NewStuff));byte[] buff = new byte[BufferSize];Array.Copy(SomeByteArray, 0, buff, 0, BufferSize);handle = GCHandle.Alloc(buff, GCHandleType.Pinned);MyStuff = (NewStuff)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(NewStuff));handle.Free(); Is there better way to accomplish this?

    Read the article

  • How to implement wait(); to wait for a notifyAll(); from enter button?

    - by Dakota Miller
    Sorry for the confusion I posted the Worng Logcat info. I updated the question. I want to click Start to start a thread then when enter is clicked i want the thad to continue and get the message and handle the message in the thread then output it to the main thread and update the text view. How would i start a thread to wait for enter to be pressed and get the bundle for the Handler? Here is my Code: public class MainActivity extends Activity implements OnClickListener { Handler mHandler; Button enter; Button start; TextView display; String dateString; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); enter = (Button) findViewById(R.id.enter); start = (Button) findViewById(R.id.start); display = (TextView) findViewById(R.id.Display); enter.setOnClickListener(this); start.setOnClickListener(this); mHandler = new Handler() { <=============================This is Line 31 public void handleMessage(Message msg) { // TODO Auto-generated method stub super.handleMessage(msg); Bundle bundle = msg.getData(); String string = bundle.getString("outKey"); display.setText(string); } }; } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.enter: Message msgin = Message.obtain(); Bundle bundlein = new Bundle(); String in = "It Works!"; bundlein.putString("inKey", in); msgin.setData(bundlein); notifyAll(); break; case R.id.start: new myThread().hello.start(); break; } } public class myThread extends Thread { Thread hello = new Thread() { @Override public void run() { // TODO Auto-generated method stub super.run(); Looper.prepare(); try { wait(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } Handler Mhandler = new Handler() { @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub super.handleMessage(msg); Bundle bundle = msg.getData(); dateString = bundle.getString("inKey"); } }; Looper.loop(); Message msg = Message.obtain(); Bundle bundle = new Bundle(); bundle.putString("outKey", dateString); msg.setData(bundle); mHandler.sendMessage(msg); } }; } } Here is the logcat info: 06-27 00:00:24.832: E/AndroidRuntime(18513): FATAL EXCEPTION: Thread-1210 06-27 00:00:24.832: E/AndroidRuntime(18513): java.lang.IllegalMonitorStateException: object not locked by thread before wait() 06-27 00:00:24.832: E/AndroidRuntime(18513): at java.lang.Object.wait(Native Method) 06-27 00:00:24.832: E/AndroidRuntime(18513): at java.lang.Object.wait(Object.java:364) 06-27 00:00:24.832: E/AndroidRuntime(18513): at com .example.learninghandlers.MainActivity$myThread$1.run(MainActivity.java:77)

    Read the article

  • Rails Updating Nested Model Collection Select

    - by Timothy
    I have a contrived nested Rails form like the following <% form_for @a do |fa| %> <% fa.fields_for :b do |fb| %> <% fb.fields_for :c do |fc| %> <%= fc.label :option_id %> <%= fc.collection_select :option_id, ModelD.all(:select => "id, name"), :id, :name %> <% end %> <% end %> <% end %> and then somewhere else on the same page I have a remote form <% remote_form_for :modeld, ModelD.new, :url => new_modeld_path, :html => {:method => 'post'} do |f| %> <%= f.label :name %> <%= f.textarea :name %> <%= f.submit "Create" %> <% end %> Is there any way I could update all the collection selects in the first form using Ajax when I submit the second form? There are an arbitrary number of collection selects.

    Read the article

  • Boost Filesystem Library Visual C++ Compile Error

    - by John Miller
    I'm having the following issue just trying to compile/run some of the example programs with the Boost Filesystem Library. I'm using MS-Visual C++ with Visual Studio .NET (2003). I've installed the Boost libraries, version 1.38 and 1.39 (just in case there was a version problem) using the BoostPro installers. If I just try to include /boost/filesystem/operations.hpp I receive the following error: \boost_1_38\boost\system\error_code.hpp(230) : error C2039: 'type' : is not a member of 'boost::enable_if<boost::system::is_error_condition_enum<Cond,boost::detail::enable_if_default_T>' Any help is greatly appreciated. Thank you!

    Read the article

  • How do I query delegation properties of an active directory user account?

    - by Mark J Miller
    I am writing a utility to audit the configuration of a WCF service. In order to properly pass credentials from the client, thru the WCF service back to the SQL back end the domain account used to run the service must be configured in Active Directory with the setting "Trust this user for delegation" (Properties - "Delegation" tab). Using C#, how do I access the settings on this tab in Active Directory. I've spent the last 5 hours trying to track this down on the web and can't seem to find it. Here's what I've done so far: using (Domain domain = Domain.GetCurrentDomain()) { Console.WriteLine(domain.Name); // get domain "dev" from MSSQLSERVER service account DirectoryEntry ouDn = new DirectoryEntry("LDAP://CN=Users,dc=dev,dc=mydomain,dc=lcl"); DirectorySearcher search = new DirectorySearcher(ouDn); // get sAMAccountName "dev.services" from MSSQLSERVER service account search.Filter = "(sAMAccountName=dev.services)"; search.PropertiesToLoad.Add("displayName"); search.PropertiesToLoad.Add("userAccountControl"); SearchResult result = search.FindOne(); if (result != null) { Console.WriteLine(result.Properties["displayName"][0]); DirectoryEntry entry = result.GetDirectoryEntry(); int userAccountControlFlags = (int)entry.Properties["userAccountControl"].Value; if ((userAccountControlFlags & (int)UserAccountControl.TRUSTED_FOR_DELEGATION) == (int)UserAccountControl.TRUSTED_FOR_DELEGATION) Console.WriteLine("TRUSTED_FOR_DELEGATION"); else if ((userAccountControlFlags & (int)UserAccountControl.TRUSTED_TO_AUTH_FOR_DELEGATION) == (int)UserAccountControl.TRUSTED_TO_AUTH_FOR_DELEGATION) Console.WriteLine("TRUSTED_TO_AUTH_FOR_DELEGATION"); else if ((userAccountControlFlags & (int)UserAccountControl.NOT_DELEGATED) == (int)UserAccountControl.NOT_DELEGATED) Console.WriteLine("NOT_DELEGATED"); foreach (PropertyValueCollection pvc in entry.Properties) { Console.WriteLine(pvc.PropertyName); for (int i = 0; i < pvc.Count; i++) { Console.WriteLine("\t{0}", pvc[i]); } } } } The "userAccountControl" does not seem to be the correct property. I think it is tied to the "Account Options" section on the "Account" tab, which is not what we're looking for but this is the closest I've gotten so far. The justification for all this is: We do not have permission to setup the service in QA or in Production, so along with our written instructions (which are notoriously only followed in partial) I am creating a tool that will audit the setup (WCF and SQL) to determine if the setup is correct. This will allow the person deploying the service to run this utility and verify everything is setup correctly - saving us hours of headaches and reducing downtime during deployment.

    Read the article

  • JavaScript window object element properties

    - by Timothy
    A coworker showed me the following code and asked me why it worked. <span id="myspan">Do you like my hat?</span> <script type="text/javascript"> var spanElement = document.getElementById("myspan"); alert("Here I am! " + spanElement.innerHTML + "\n" + myspan.innerHTML); </script> I explained that a property is attached to the window object with the name of the element's id when the browser parses the document which then contains a reference to the appropriate dom node. It's sort of as if window.myspan = document.getElementById("myspan") is called behind the scenes as the page is being rendered. The ensuing discussion we had raised a few of questions: The window object and most of the DOM are not part of the official JavaScript/ECMA standards, but is the above behavior documented in any other official literature, perhaps browser-related? The above works in a browser (at least the main contenders) because there is a window object, but fails in something like rhino. Is writing code that relys on this considered bad practice because it makes too many assumptions about the execution environment? Are there any browsers in which the above would fail, or is this considered standard behavior across the board? Does anyone here know the answers to those questions and would be willing to enlighten me? I tried a quick internet search, but I admit I'm not sure how to even properly phrase the query. Pointers to references and documentation are welcome.

    Read the article

  • Question about unions and heap allocated memory

    - by Dennis Miller
    I was trying to use a union to so I could update the fields in one thread and then read allfields in another thread. In the actual system, I have mutexes to make sure everything is safe. The problem is with fieldB, before I had to change it fieldB was declared like field A and C. However, due to a third party driver, fieldB must be alligned with page boundary. When I changed field B to be allocated with valloc, I run into problems. Questions: 1) Is there a way to statically declare fieldB alligned on page boundary. Basically do the same thing as valloc, but on the stack? 2) Is it possible to do a union when field B, or any field is being allocated on the heap?. Not sure if that is even legal. Here's a simple Test program I was experimenting with. This doesn't work unless you declare fieldB like field A and C, and make the obvious changes in the public methods. #include <iostream> #include <stdlib.h> #include <string.h> #include <stdio.h> class Test { public: Test(void) { // field B must be alligned to page boundary // Is there a way to do this on the stack??? this->field.fieldB = (unsigned char*) valloc(10); }; //I know this is bad, this class is being treated like //a global structure. Its self contained in another class. unsigned char* PointerToFieldA(void) { return &this->field.fieldA[0]; } unsigned char* PointerToFieldB(void) { return this->field.fieldB; } unsigned char* PointerToFieldC(void) { return &this->field.fieldC[0]; } unsigned char* PointerToAllFields(void) { return &this->allFields[0]; } private: // Is this union possible with field B being // allocated on the heap? union { struct { unsigned char fieldA[10]; //This field has to be alligned to page boundary //Is there way to be declared on the stack unsigned char* fieldB; unsigned char fieldC[10]; } field; unsigned char allFields[30]; }; }; int main() { Test test; strncpy((char*) test.PointerToFieldA(), "0123456789", 10); strncpy((char*) test.PointerToFieldB(), "1234567890", 10); strncpy((char*) test.PointerToFieldC(), "2345678901", 10); char dummy[11]; dummy[10] = '\0'; strncpy(dummy, (char*) test.PointerToFieldA(), 10); printf("%s\n", dummy); strncpy(dummy, (char*) test.PointerToFieldB(), 10); printf("%s\n", dummy); strncpy(dummy, (char*) test.PointerToFieldC(), 10); printf("%s\n", dummy); char allFields[31]; allFields[30] = '\0'; strncpy(allFields, (char*) test.PointerToAllFields(), 30); printf("%s\n", allFields); return 0; }

    Read the article

  • visual analysis of web pages in ruby

    - by Clint Miller
    I'm looking to write some code that does visual analysis of web pages, preferably using Ruby. My code will need to be able to determine the top, left, width, height, background color, color, and font size for all the elements in the DOM. Of course, these values can only be calculated once all CSS is applied. So, I don't think that Nokogiri is up for the job. Ultimately, I'm trying to use this data in a VIPS-like (Vision-Based Page Segmentation) algorithm in an attempt to find the main content in downloaded news articles. I've considered using Watir to drive Chrome or Firefox and then extract the data. The problem is that browsers can't be run headless through Watir (I think). Ultimately, this code will be running on an array of Linux servers in a data center. So, the code won't have easy access to an X Server for displaying the browser. I suppose one solution is to use Watir and run a headless X Server on the Linux servers. That's a bit of a pain, but it looks like my best option right now. Does anyone have any better ideas?

    Read the article

  • In WPF, how do I update the object that my custom property is bound to?

    - by Timothy Khouri
    I have a custom property that works perfectly, except when it's bound to an object. The reason is that once the following code is executed: base.SetValue(ValueProperty, value); ... then my control is no longer bound. I know this because calling: base.GetBindingExpression(ValueProperty); ... returns the binding object perfectly - UNTIL I call base.SetValue. So my question is, how do I pass the new "value" on to the object that I'm bound to?

    Read the article

  • Query Parameter Value Is Null When Enum Item 0 is Cast with Int32

    - by Timothy
    When I use the first item in a zero-based Enum cast to Int32 as a query parameter, the parameter value is null. I've worked around it by simply setting the first item to a value of 1, but I was wondering though what's really going on here? This one has me scratching my head. Why is the parameter value regarded as null, instead of 0? Enum LogEventType : int { SignIn, SignInFailure, SignOut, ... } private static DataTable QueryEventLogSession(DateTime start, DateTime stop) { DataTable entries = new DataTable(); using (FbConnection conn = new FbConnection(DSN)) { using (FbDataAdapter adapter = new FbDataAdapter( "SELECT event_type, event_timestamp, event_details FROM event_log " + "WHERE event_timestamp BETWEEN @start AND @stop " + "AND event_type IN (@signIn, @signInFailure, @signOut) " + "ORDER BY event_timestamp ASC", conn)) { adapter.SelectCommand.Parameters.AddRange(new Object[] { new FbParameter("@start", start), new FbParameter("@stop", stop), new FbParameter("@signIn", (Int32)LogEventType.SignIn), new FbParameter("@signInFailure", (Int32)LogEventType.SignInFailure), new FbParameter("@signOut", (Int32)LogEventType.SignOut)}); Trace.WriteLine(adapter.SelectCommand.CommandText); foreach (FbParameter p in adapter.SelectCommand.Parameters) { Trace.WriteLine(p.Value.ToString()); } adapter.Fill(entries); } } return entries; }

    Read the article

  • I keep getting a no match for call to error!!??

    - by Timothy Poseley
    #include <iostream> #include <string> using namespace std; // Turns a digit between 1 and 9 into its english name // Turn a number into its english name string int_name(int n) { string digit_name; { if (n == 1) return "one"; else if (n == 2) return "two"; else if (n == 3) return "three"; else if (n == 4) return "four"; else if (n == 5) return "five"; else if (n == 6) return "six"; else if (n == 7) return "seven"; else if (n == 8) return "eight"; else if (n == 9) return "nine"; return ""; } string teen_name; { if (n == 10) return "ten"; else if (n == 11) return "eleven"; else if (n == 12) return "twelve"; else if (n == 13) return "thirteen"; else if (n == 14) return "fourteen"; else if (n == 14) return "fourteen"; else if (n == 15) return "fifteen"; else if (n == 16) return "sixteen"; else if (n == 17) return "seventeen"; else if (n == 18) return "eighteen"; else if (n == 19) return "nineteen"; return ""; } string tens_name; { if (n == 2) return "twenty"; else if (n == 3) return "thirty"; else if (n == 4) return "forty"; else if (n == 5) return "fifty"; else if (n == 6) return "sixty"; else if (n == 7) return "seventy"; else if (n == 8) return "eighty"; else if (n == 9) return "ninety"; return ""; } int c = n; // the part that still needs to be converted string r; // the return value if (c >= 1000) { r = int_name(c / 1000) + " thousand"; c = c % 1000; } if (c >= 100) { r = r + " " + digit_name(c / 100) + " hundred"; c = c % 100; } if (c >= 20) { r = r + " " + tens_name(c /10); c = c % 10; } if (c >= 10) { r = r + " " + teen_name(c); c = 0; } if (c > 0) r = r + " " + digit_name(c); return r; } int main() { int n; cout << endl << endl; cout << "Please enter a positive integer: "; cin >> n; cout << endl; cout << int_name(n); cout << endl << endl; return 0; } I Keep getting this Error code: intname2.cpp: In function âstd::string int_name(int)â: intname2.cpp:74: error: no match for call to â(std::string) (int)â intname2.cpp:80: error: no match for call to â(std::string) (int)â intname2.cpp:86: error: no match for call to â(std::string) (int&)â intname2.cpp:91: error: no match for call to â(std::string) (int&)â

    Read the article

  • Are there any frameworks for data subscription and update?

    - by Timothy Pratley
    There is one server with multiple clients. The clients are viewing subsets of the servers entire data. If the data that a client is viewing changes, the client should be informed of the changes so that it displays the current data. Example: Two clients are viewing a list of users in an administration screen. One client adds a new user to the list and modifies the permissions of another user. The other client sees the changes propagated to their view.

    Read the article

  • C++ OOP - Can you 'overload a cast' <- hard to explain in 1 sentence

    - by Brandon Miller
    Well, the WinAPI has a POINT struct, but I am trying to make an alternative class to this so you can set the values of x and y from a constructor. /** * X-Y coordinates */ class Point { public: int X, Y; Point(void) : X(0), Y(0) {} Point(int x, int y) : X(x), Y(y) {} Point(const POINT& pt) : X(pt.x), Y(pt.y) {} Point& operator= (const POINT& other) { X = other.x; Y = other.y; } }; // I have an assignment operator and copy constructor. Point myPtA(3,7); Point myPtB(8,5); POINT pt; pt.x = 9; pt.y = 2; // I can assign a 'POINT' to a 'Point' myPtA = pt; // But I also want to be able to assign a 'Point' to a 'POINT' pt = myPtB; Is it possible to overload operator= in a way so that I can assign a Point to a POINT? Or maybe some other method to achieve this? Thanks in advance.

    Read the article

  • Query Parameter Value Is Null When Enum Item 0 is Cast to Int32

    - by Timothy
    When I use the first item in a zero-based Enum cast to Int32 as a query parameter, the parameter value is null. I've worked around it by simply setting the first item to a value of 1, but I was wondering though what's really going on here? This one has me scratching my head. Why does the parameter regarded the value as null, instead of 0? Enum LogEventType : int { SignIn, SignInFailure, SignOut, ... } private static DataTable QueryEventLogSession(DateTime start, DateTime stop) { DataTable entries = new DataTable(); using (FbConnection conn = new FbConnection(DSN)) { using (FbDataAdapter adapter = new FbDataAdapter( "SELECT event_type, event_timestamp, event_details FROM event_log " + "WHERE event_timestamp BETWEEN @start AND @stop " + "AND event_type IN (@signIn, @signInFailure, @signOut) " + "ORDER BY event_timestamp ASC", conn)) { adapter.SelectCommand.Parameters.AddRange(new Object[] { new FbParameter("@start", start), new FbParameter("@stop", stop), new FbParameter("@signIn", (Int32)LogEventType.SignIn), new FbParameter("@signInFailure", (Int32)LogEventType.SignInFailure), new FbParameter("@signOut", (Int32)LogEventType.SignOut)}); Trace.WriteLine(adapter.SelectCommand.CommandText); foreach (FbParameter p in adapter.SelectCommand.Parameters) { Trace.WriteLine(p.Value.ToString()); } adapter.Fill(entries); } } return entries; }

    Read the article

  • jQuery: preventdefault does not work

    - by Kent Miller
    I somehow cannot achieve that the a-tag looses its default action when clicking it: <a href="#" class="button dismiss">dismiss</a> $(document).ready(function() { $('.dismiss').click(function(e) { e.preventDefault(); $('#output').empty(); $('#MyUploadForm .button').show(); }); }); When I click the button, the browser window scrolls to the top. What is wrong here?

    Read the article

  • What frameworks exist for data subscription and update?

    - by Timothy Pratley
    There is one server with multiple clients. The clients are viewing subsets of the servers entire data. If the data that a client is viewing changes, the client should be informed of the changes so that it displays the current data. Example: Two clients are viewing a list of users in an administration screen. One client adds a new user to the list and modifies the permissions of another user. The other client sees the changes propagated to their view. In the client side code I would like the users list to be updated by the framework itself, raising changed events such that it will be redrawn - similar to 'cells' or dataflow. I am looking specifically for a .NET or java implementation.

    Read the article

  • Can i use a switch to hold a function?

    - by TIMOTHY
    I have a 3 file program, basically teaching myself c++. I have an issue. I made a switch to use the math function. I need and put it in a variable, but for some reason I get a zero as a result. Also another issue, when I select 4 (divide) it crashes... Is there a reason? Main file: #include <iostream> #include "math.h" #include <string> using namespace std; int opersel; int c; int a; int b; string test; int main(){ cout << "Welcome to Math-matrix v.34"<< endl; cout << "Shall we begin?" <<endl; //ASK USER IF THEY ARE READY TO BEGIN string answer; cin >> answer; if(answer == "yes" || answer == "YES" || answer == "Yes") { cout << "excellent lets begin..." << endl; cout << "please select a operator..." << endl << endl; cout << "(1) + " << endl; cout << "(2) - " << endl; cout << "(3) * " << endl; cout << "(4) / " << endl; cin >> opersel; switch(opersel){ case 1: c = add(a,b); break; case 2: c = sub(a,b); break; case 3: c = multi(a,b); break; case 4: c = divide(a,b); break; default: cout << "error... retry" << endl; }// end retry cout << "alright, how please select first digit?" << endl; cin >> a; cout << "excellent... and your second?" << endl; cin >> b; cout << c; cin >> test; }else if (answer == "no" || answer == "NO" || answer == "No"){ }//GAME ENDS }// end of int main Here is my math.h file #ifndef MATH_H #define MATH_H int add(int a, int b); int sub(int a, int b); int multi(int a, int b); int divide(int a, int b); #endif Here is my math.cpp: int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } int multi(int a, int b) { return a * b; } int divide(int a, int b) { return a / b; } }// end of int main

    Read the article

  • How to get a collection of divs with jquery?

    - by Gal Miller
    I want to get the second img: <form id="formElem" name="formElem" action="" method="post"> <fieldset class="step"> <img src="1.jpg" > </fieldset> <fieldset class="step"> <img src="2.jpg" > </fieldset> <fieldset class="step"> <img src="3.jpg" > </fieldset> </form> I tried doing something like: var imgSRC = $("div[id ='step']").get(1).find('img').attr('src'); alert(imgSRC); Got nothing....

    Read the article

  • F# insert/remove item from list

    - by Timothy
    How should I go about removing a given element from a list? As an example, say I have list ['A'; 'B'; 'C'; 'D'; 'E'] and want to remove the element at index 2 to produce the list ['A'; 'B'; 'D'; 'E']? I've already written the following code which accomplishes the task, but it seems rather inefficient to traverse the start of the list when I already know the index. let remove lst i = let rec remove lst lst' = match lst with | [] -> lst' | h::t -> if List.length lst = i then lst' @ t else remove t (lst' @ [h]) remove lst [] let myList = ['A'; 'B'; 'C'; 'D'; 'E'] let newList = remove myList 2 Alternatively, how should I insert an element at a given position? My code is similar to the above approach and most likely inefficient as well. let insert lst i x = let rec insert lst lst' = match lst with | [] -> lst' | h::t -> if List.length lst = i then lst' @ [x] @ lst else insert t (lst' @ [h]) insert lst [] let myList = ['A'; 'B'; 'D'; 'E'] let newList = insert myList 2 'C'

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11  | Next Page >