[Solved] for loop: make increment and accessing in one loop

doing for( int i =0; i++<10; a[i-1]=i ) { printf(“%i:%i\n”, i-1, a[i-1]); } you set the entries after you print them because a[i-1]=i is executed after the body of the for, so you print non initialized array entries your code is also ‘complicated’ because you increase i too earlier in the test part of for, … Read more

[Solved] Create Channel Switch Logger

Your bot does not respond because the client is not initialized correctly. You’re creating the client like this: var bot = new Discord.Client({ token: auth.token, // <– autorun: true // <– }); The problem is that these arguments do not exist in discord.js, as stated by the Client docs. To log into your bot, please … Read more

[Solved] Applying static keyword to a class in java [duplicate]

Top-level classes cannot be static, because the static keyword represents a relation between a class/member/method and the enclosing class. As the top-level classes don’t have an enclosing class, then the static keyword doesn’t makes sense in this case. solved Applying static keyword to a class in java [duplicate]

[Solved] Reading and processing input [closed]

Proper method: Int32 weeklySales = 0; while (weeklySales.Equals(0)) { Console.WriteLine(“What are your weekly sales?”); String input = Console.ReadLine(); try { weeklySales = Int32.Parse(input); } catch { Console.WriteLine(“There is an error in your input, try again!”); } } Double grossPay = weeklySales * .07; Double fedTax = grossPay * .18; Double retirement = grossPay * .1; … Read more

[Solved] Checking all values in an array [duplicate]

You can check every element in the array and break if only the element is smaller than 100. And outside the loop print the message based on whether i – The loop counter- is equal to the size or not. If equal than all elements are greater otherwise one of them is smaller: int array[] … Read more

[Solved] Query database then email posts from where user is subbed to

I figured it out. Just use ob_start(), and loop through each user. Select the posts they’re subscribed to. Then inside the loop email it to each user. I used this query SELECT articles.* FROM articles INNER JOIN subscriptions ON articles.from_id = subscriptions.sub_to INNER JOIN users ON subscriptions.user_id = users.id WHERE users.email = :email 5 solved … Read more

[Solved] Why is Python strict about indentation? [closed]

Indentation is essential in Python; it replaces curly braces, semi-colons, etc. in C-like syntax. Consider this code snippet, for example: def f(x): if x == 0: print(“x is zero”) print(“where am i?”) If it weren’t for indentation, we would have no way of indicating what code block the second print statement belongs to. Is it … Read more

[Solved] TableViewCell in Swift?

This should be about right: func tableView(tableView: UITableView, indexPath: NSIndexPath) { let cell = tableView.cellForRowAtIndexPath(indexPath); let cellText = cell.textLabel.text; } 4 solved TableViewCell in Swift?

[Solved] How to insert variable as a string into MySQL in Java

In general you can create strings with placeholders using: String result = String.format(“%s,%s”, v1, v2); If you are using JDBC, you can use a PreparedStatement, for example: PreparedStatement statement = connection.prepareStatement(“UPDATE table1 SET column1 = ? WHERE column2 = ?”); int i = 1; statement.setInt(i++, v1); statement.setInt(i++, v2); statement.executeUpdate(); For creating JDBC queries the PreparedStatement … Read more

[Solved] C++ : Unable to read from large txt file [closed]

Your problem is in the merge function: you exceed the local variable c. long c[30]; maybe there are more problems, that is the first I notice. EDIT Try this: find the differences… #include <map> #include <vector> #include <fstream> #include <iostream> #include <time.h> using namespace std; void merge(vector<long> &,long ,long , long ); void divide(vector<long> &arr,long … Read more

[Solved] free() not working correctly with struct

It is always a good habit to set the pointer to NULL after freeing it. Since the memory you are accessing is still intact you are seeing right values for l->val. Node *l=malloc(sizeof(Node)); l->key=”foo”; l->val=”bar”; free(l); l = NULL; solved free() not working correctly with struct

[Solved] how to store and retrieve array in mysql [closed]

Looks like you’re using the php script to construct a sql statement. I do this all the time. Try something like: $galleryIds = implode(“,”,$galleries); $sql = “SELECT * FROM galleries WHERE id IN ($galleryIds)”; Cheers and please vote me up!! OK, Here’s an edit because it seems that the Stack thinks you’re going to use … Read more