When I compile this program I only get the first capital letter but not the rest.
Input:
ABldjfdslkjfCK
I only get 'A' that is it?
#include <stdio.h>
#include <string.h>
FILE *fp;
int main(void)
{
int size;
char input[100]; // array size of 100
if (fp = fopen("message.txt","r")) // file exists
{
fge...
I'm trying to create a utility class for traversing all the files in a directory, including those within subdirectories and sub-subdirectories. I tried to use a generator because generators are cool; however, I hit a snag.
def grab_files(directory):
for name in os.listdir(directory):
full_path = os.path.join(directory, name...
I have several data that looks like this:
Vector1_elements = T,C,A
Vector2_elements = C,G,A
Vector3_elements = C,G,T
..... up to ...
VectorK_elements = ...
#Note also that the member of each vector is always 3.
What I want to do is to create all combination of elements in Vector1 through out VectorK.
Hence in the end we hope to get t...
I have an interesting problem. The basis of the problem is that my last iteration of an array reference doesn't
seem to "stick," if you will. A little context: I've devised a very simple data structure for page heirarchy that
looks like this:
,1,2,3>,4>,5,6,7<<,8
Translation: forget about the annoying leading commas. Pages 1, 2, 3, & 8...
I tried to print all the possible combination of members of several vectors. Why
the function below doesn't return the string as I expected?
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
using namespace std;
string EnumAll(const vector<vector<string> > &allVecs, size_t vecIndex, string
strSoFar)
{...
Is there any command to recursively remove .listing files from a Windows folder?
...
I have the following array that I need to recursively loop through and remove any child arrays that have the key 'fields'. I have tried array filter but I am having trouble getting any of it to work.
$myarray = array(
'Item' => array(
'fields' => array('id', 'name'),
'Part' => array(
'fields' => array('pa...
cat_id prod_name parent_cat_id
------ ---------- ------------
1 prod_1 2
2 prod_2 5
3 prod_3 1
4 prod_4 3
5 prod_5 7
6 prod_6 5
In a recursive function, make a table and by using these, if cat_id = 1 and parent_cat_id = 1 take that product name and if that product category id and parent category id is sam...
I am currently reading Simon Thompson's The Craft of Functional Programming and when describing recursion, he also mentions a form of recursion called Primitive Recursion.
Can you please explain how this type of recursion is different from "normal" recursive functions?
Here's an example of a primitive recursion function (in Haskell):
...
function generate_session_id( &$db )
{
$user_sess_id = md5( uniqid( mt_rand(), true );
try
{
$stmt = $db->prepare("SELECT COUNT(*) AS session_exists FROM sessions WHERE session_id = :session_id");
$stmt->bindParam(':session_id', $user_sess_id);
$stmt->execute();
$result = $stmt->fetch( PDO::FE...
In an ASPX page, I have 7 user controls loaded. In each user control there are data bound controls (gridview for example).
Currently each user control runs a query to return data. The data returned is the same for each user control, and I filter out what I need to show for each user control. So the same query is being run 7 times (Ye...
Does pthreads support any method that allows you to query the number of times a recursive mutex has been locked?
...
Hey I'm working on a problem where you would print a string vertically using recursion. I know how to do this if i were to use a for loop:
for (int i = 0; i < str.length(); i++) {
System.out.println(str.charAt(i));
but i'm not entirely sure how to do it using recursion. I took care of the base case but i'm not sure how to continue...
I'm trying to figure out how to build a recursive binding in xaml. I know about HierarchialDataTemplate, but that's not what I want, because my data source is not a collection of items. Specifically, I'm building an exception browser, and am trying to figure out the best way of expressing the exception's InnerException field (which is of...
I have the following binary tree
A
/ \
B C
/ \
D E
represented as a list in Lisp (A 2 B 0 C 2 D 0 E 0) where the letters are node names and the numbers are the number of child nodes (0 for none, 1 one node, 2 two nodes). I need to find highest from root node to leaf depth of the tree (the depth of the binary tree that is)...
I am trying to write a method that uses recursion to compare the strings str1 and str2 and determine which of them comes first alphabetically (i.e., according to the ordering used for words in a dictionary).
If str1 comes first alphabetically, the method should return the integer 1.
If str2 comes first alphabetically, the method shoul...
I'm trying to write a method that uses recursion to print the string formed by "interleaving" the strings str1 and str2. In other words, it should alternate characters from the two strings: the first character from str1, followed by the first character from str2, followed by the second character from str1, followed by the second charact...
I don't know why the following haskell source code for calculating products recursively only using addition doesn't work.
mult a b = a + mult a (b-1)
I'm always getting a stack overflow error.
...
Hello all,
I am creating a quick backup script that will dump some databases into a nice/neat directory structure and I realized that I need to test to make sure that the directories exist before I create them. The code I have works, but it seems that there is a better way to do it. Any suggestions?
[ -d "$BACKUP_DIR" ] || mkdir "$BACK...
I've got a database table that represents a bunch of trees. The first three columns are GUIDs that look like this:
NODE_ID (PK)
PARENT_NODE_ID (FK to same table, references NODE_ID)
TREE_ID (FK to another table)
It's possible to move a node to a different tree. The tricky part is bringing all its child-nodes with it. That takes a r...