133 Posted Topics

Member Avatar for 46agogo

Maybe try [getaddrinfo(name, port, &hints, &result)](http://msdn.microsoft.com/en-us/library/windows/desktop/ms738520%28v=vs.85%29.aspx). There is an example at the bottom of the page. >pNodeName: A pointer to a NULL-terminated ANSI string that contains a host (node) name or a numeric host address string. For the Internet protocol, the numeric host address string is a dotted-decimal IPv4 address …

Member Avatar for histrungalot
0
486
Member Avatar for brandon93s

Let's add more debug. Not making it into the for loop. **Code** #include <stdio.h> #include <stdlib.h> typedef struct IntNode { int data; struct IntNode *next; } IntNode; typedef struct List { IntNode *head; } List; IntNode *New_Node(int n); void Print_List(List *theList); void Free_List(List *theList); void Add_in_Order(List *list, IntNode *newnode); IntNode …

Member Avatar for histrungalot
0
590
Member Avatar for cryonize

Its taking a while to understand how you are doing it. So, I wrote it my way. The first thing I do see is that you are not swapping the min value with the head. http://en.wikipedia.org/wiki/Selection_sort 1. Find the minimum value in the list 2. `**Swap**` it with the value …

Member Avatar for Nick Evan
0
592
Member Avatar for pattilupwned

I started to look at your issues but wound up rewritting the whole translateWord. Not what I wanted. So, I don't know if this will help, I will post the pseudocode. That way you can see some of the things I did to handle you issues. **Differentiate between y as …

Member Avatar for pattilupwned
0
2K
Member Avatar for pjh-10

[quote=Moschops]Get a decent random number generator[/quote] I would have to be a uniformly distributed random number generator right? Or is that part of the simulation, normal vs. uniform?

Member Avatar for pjh-10
0
443
Member Avatar for jackmaverick1

http://en.wikipedia.org/wiki/Circular_dependency Look at where it says Example of circular dependencies in C++. You need the class Map in Rabbit but Rabbit needs class Map. Hence circular dependency. Fix it with a forward declaration #ifndef RABBIT_H #define RABBIT_H // Remove the #include "Map.h" and use a // forward declaration class Map; …

Member Avatar for histrungalot
0
394
Member Avatar for BryantFury

I took you code and made some small changes. Doing it this way fixes what you want to do. I tried to modify your code as little as possible #include <iostream> #include <fstream> using namespace std; class student { private: char grade; int calc; public: string first; string last; int …

Member Avatar for BryantFury
0
188
Member Avatar for afzal123

Lines 72, 94, 114, 156 and 187 all need more memory. Try char name[128]; // Or larger if you need it Now when you facanf or scanf into name you will have memory. See if that fixes it.

Member Avatar for histrungalot
0
156
Member Avatar for phorce

Your number of sub-matrices isn't right. I think below is right but test it and test it some more. #include <iostream> #include <fstream> #include <sstream> #include <iterator> #include <vector> using namespace std; typedef vector<double> Matrix; // Had to pass input matrix size and output matrix size // Not using matRow …

Member Avatar for histrungalot
0
202
Member Avatar for phorce

Not following what you want to do. What does swap them or create a new matrix mean? In formatMatrix the input is a 1D vector, so what happen to the matrix? Can you post an example with matrix1 and matrix2 input and what the output should be?

Member Avatar for histrungalot
0
105
Member Avatar for adohertyd

When using char fname[MAXLEN]; you have to use strcpy or strncpy. http://linux.die.net/man/3/strncpy Like: strcpy(person.fname,fname); strcpy( personcpy.fname,person.fname); To use strcpy or strncpy add file #include <cstring> or you could use C++ strings and just use = to copy strings. http://www.cplusplus.com/reference/string/string/operator=

Member Avatar for histrungalot
0
275
Member Avatar for wildplace

This works. You have to wait for all started. #include <sys/types.h> #include <sys/wait.h> #include <cstdlib> #include <iostream> #include <unistd.h> using namespace std; int main(){ int pid,i,numOfProcess(10); for(i=0; i<numOfProcess; i++){ pid = fork(); // <-------- You had a == not = if(pid == -1){ // <-------- You didn't have a open …

Member Avatar for histrungalot
0
11K
Member Avatar for abed1986

[code]#!/bin/sh read coursepath echo $coursepath | sed -ne 's/.*COSC[^0-9]*\(.*\)/\1/p' [/code]

Member Avatar for abed1986
0
141
Member Avatar for shean1488
Member Avatar for rubberman
0
115
Member Avatar for funkey100

If you want to use a \ in a string do two of them back to back like "user\\". Line 40 use 'g'. When you want a char you have to use ' not " which is for a string.

Member Avatar for histrungalot
0
369
Member Avatar for gourav1

Take a look at http://www.daniweb.com/software-development/c/threads/417121/calculating-powers-of-2, I got his program to calculate 2^50000 in 1.5 seconds.

Member Avatar for TrustyTony
0
1K
Member Avatar for hwoarang69

You can't use `if(ar[i] == ar[j])` because that is testing if the pointer values are equal not if the string are equal. You need to use `if ( strcmp(ar[i],ar[j]) == 0 )` to check if two strings are equal. If `strcmp` return 0 they are equal. Also there is an …

Member Avatar for hwoarang69
0
117
Member Avatar for minghags
Member Avatar for minghags
0
123
Member Avatar for jaclynkinsey

It is the mixing of the getline and operator>>. getline removes the '\n' if found but the last >> does not. So the first one works but the next getline reads the '\n' from the Newland data and then the >> tries to read the next line which is China …

Member Avatar for jaclynkinsey
0
169
Member Avatar for akash.doe

Maybe something like: #include <iostream> #include <string> int main(){ std::cout << std::string("No name").c_str() << std::endl; // Or std::cout << std::string("No name") << std::endl; return 0; }

Member Avatar for thines01
0
85
Member Avatar for DJXiej

The code you posted didn't compile. test.c: In function ‘shuffle’: test.c:14: error: subscripted value is neither array nor pointer test.c:14: error: subscripted value is neither array nor pointer test.c:14: error: subscripted value is neither array nor pointer test.c:14: error: subscripted value is neither array nor pointer test.c:14: error: subscripted value …

Member Avatar for histrungalot
0
453
Member Avatar for garu525

Try string streams: [code]#include <iostream> #include <iomanip> #include <sstream> using namespace std; string conv (int num, int base,int pad=0) { if (num == 0) return "0000000000000000"; char NUMS[] = "0123456789ABCDEF"; string result = ""; do { result.push_back (NUMS[num % base]); num /= base; } while (num != 0); stringstream strStrm; …

Member Avatar for histrungalot
0
143
Member Avatar for triumphost
Member Avatar for ilovephil

You were passing in number to the push function and setting the node->data to that value which was some random value coming off of the stack. Take a look at the changes I made, I put comments in to explain. [code]#include<stdio.h> #include<stdlib.h> #define p printf #define s scanf #include<ctype.h> struct …

Member Avatar for histrungalot
0
174
Member Avatar for Detkimble

The main issue was that you defined a variable in main() called [B][COLOR="Red"]number_of_threads[/COLOR][/B] and a global variable [B][COLOR="Green"]number_of_threads[/COLOR][/B]. When you read in the value of number_of_threads it was to the local variable and not the global. So, when the threads read the value of the global number_of_threads it was ZERO. …

Member Avatar for Detkimble
0
165
Member Avatar for DNA_Monk

After you pull all of the unique left side ID's, how many are there? And are they all 15 characters? How much memory do you have on your machine?

Member Avatar for histrungalot
0
157
Member Avatar for triumphost
Member Avatar for triumphost
0
250
Member Avatar for a.muqeet khan

Not sure what you want to do but this does something. I don't have windows so I removed and replaced some things. Many things going on here so take look and ask questions. [code]#include <iostream> //# define size 10; int mergesort(int,int); using namespace std; int main(int argc, char* argv[]) { …

Member Avatar for Tumlee
0
165
Member Avatar for niyasc

There is no problem with your code. You just need to wait for the output to come out. Or you could call [icode]fflush(stdout)[/icode] after the [icode]printf("Waiting for p2 and p3 to complete");[/icode] or put newlines (\n) at the end of your print statements. Other then that its working, it just …

Member Avatar for niyasc
0
211
Member Avatar for swissknife007

Line 22 should be [icode]for(i=16603;i>=0;i--)[/icode] because bin has 16604 elements. As for the speed up, you don't have to loop over all 16604 (in that same for loop) elements because the number of digits in the number 2^n is n*log10(2). Only go to the ceil(n*log10(2)) in the for loop. That …

Member Avatar for histrungalot
0
206
Member Avatar for triumphost
Member Avatar for triumphost
0
150
Member Avatar for Mr.UNOwen

To block threads you might want to try [url]https://computing.llnl.gov/tutorials/pthreads/#ConditionVariables[/url]

Member Avatar for histrungalot
0
200
Member Avatar for triumphost

To get it right you need to pad the binary numbers out to 8 so when you group them by 6 you get the right answer [code]#include <iostream> #include <iomanip> #include <string> #include <sstream> using namespace std; #define Ord(c) ((int)(unsigned char)(c)) string DecToBin(int Num){ int Bin = 0, Pos = …

Member Avatar for histrungalot
0
206
Member Avatar for cdea06

You can do it all in the first for loop. All you need to do is save the start of a word in the array_str like [icode]array_str[j++] = &array_char[i];[/icode] and insert the '\0' as you are doing. Here is a way to get rid the '\n'. [code] #include<stdio.h> #include<string.h> int …

Member Avatar for cdea06
0
258
Member Avatar for aldrin_ison1

Two things: 1. Take a look at what strtok is returning [code]./a.out love MONEY text.txt t.new.txt New file <t.new.txt> generated! [love] [is] [B][COLOR="Red"][patient love][/COLOR][/B] [is] [kind ] [/code] The first "love" matches because it matches. The second one doesn't match because it is "patient\nlove". 2. You can't copy the newwork …

Member Avatar for histrungalot
0
461
Member Avatar for zingwing

Here is a staring point. You started to use the inAWord but didn't take it all of the way. Think of it like in a word, not in a word, in a word, not in a word, etc... changing the value of inAWord as you go. Also there are some …

Member Avatar for zingwing
0
192
Member Avatar for rbran74

Line 77, don't subtract 1. This is preventing you from printing out the last item. What would happen if you only had one item in the file? i would come out of the loop with the value of 1 and you would subtract 1 leaving size equal to ZERO. Then …

Member Avatar for histrungalot
0
137
Member Avatar for Vasthor

numstore.size is a function, not a member. Add the () to get it to compile. And change /n to \n. [code] // Error if ((quartiles == 2) && (numstore.size / 2 == 0)) // Fixed if ((quartiles == 2) && (numstore.size() / 2 == 0)) [/code]

Member Avatar for histrungalot
0
1K
Member Avatar for Adnan671

Maybe something like this. [code]#include <stdio.h> #include <iostream> // # 3 #include <vector> #include "Fairy.h" #include "GoodFairy.h" #include "EvilFairy.h" #include "EquiFairy.h" using namespace std; // # 1 bool loadFairy(string infile,vector<Fairy *> &f){ bool ret(true); // Use ifstream to open and read data in infile // If file is open // …

Member Avatar for Adnan671
0
134
Member Avatar for PyroPlasm

I think you could use sed or egrep. [code=shell]$ cat test.txt ----------- 50 (1 rows affected) $ sed -ne '/^[0-9]/p' test.txt 50 $ egrep "^[0-9]" test.txt 50 $ [/code]

Member Avatar for histrungalot
0
169
Member Avatar for abed1986

You are not allocating memory for the string value. Each time you add a node you are setting the string pointer to the same place and that place would be the memory of [icode]char word[50][/icode]. To fix you need to do a malloc of 50 bytes to [icode]n->string = (char …

Member Avatar for abed1986
0
823
Member Avatar for Quicxic

I got this from [url]http://stackoverflow.com/questions/115703/storing-c-template-function-definitions-in-a-cpp-file[/url] The problem you describe can be solved by defining the template in the header, or via the approach you describe above. I recommend reading points 35.12, 35.13, and 35.14 from the C++ FAQ Lite: [url]http://www.parashift.com/c++-faq-lite/templates.html[/url]

Member Avatar for Quicxic
0
202
Member Avatar for Labdabeta

Did you see this site? [url]http://www.songho.ca/dsp/convolution/convolution2d_example.html[/url]

Member Avatar for Labdabeta
0
138
Member Avatar for Dr_Freeman

You could use Maclaurin series expansion for e^x = Sum(x^n/n!,0..N) were you pick N to give the you precision want. The power here is always an integer so that is just a for loop. And the factorial is just another loop.

Member Avatar for histrungalot
0
624
Member Avatar for coding101

server.c [code] // Add read from client connection write(clientfd,message,c); int b[2]; while(read(clientfd,b,1) > 0){ /* Don't have the check here because the client closes the socket and that causes the return from the read to be -1 and while loop with exit */ printf("%c",b[0]); b[1] = '\0'; } printf("\n"); close(sockfd); …

Member Avatar for histrungalot
0
217
Member Avatar for newbie14

If I understand what you want, you have to loop thru the whole "packet" printing each hex byte. You want the output to look like that of the unix/linux command od: [code] 0000000 cf fa ed fe 07 00 00 01 03 00 00 80 02 00 00 00 0000010 …

Member Avatar for newbie14
0
474
Member Avatar for hey.howdy

The link makes it clear. The code that you posted is not the code on the video. The code in video has this block of code [code]while(true){ int i = 0; while (i<80){ if(caRow[i]!=' ') { caRow[i]=GetChar(j+i*i,33,30); } std::cout << caRow[i]; i++; } j = (j+31); k = (k+17); l …

Member Avatar for histrungalot
0
211
Member Avatar for hey.howdy

Not sure what it is suppose to do, but what it does is for me after I got it to compile is repeat the same pattern every 1200 chars for infinity. The modulo function is correct. ((7+9)%30)+33 = 7+9+33 so it did what it should have. [code]cout << ::modulus(11,3) << …

Member Avatar for histrungalot
1
135
Member Avatar for davi0011

You need to have room for '\0'. Change [code] int EnORDe; char a,b; char newline='\n'; // <--- Changed, was getting a warning can't have two chars set to one char int pavalue[33]; // <--- 32 to 33 <--------------LOOK HERE //--------------- //reads passcode for value of array to use void passcode(int …

Member Avatar for davi0011
0
354
Member Avatar for Xheis

Change line 208 to be [code] } while (passes <= 2 && slot->burst <= slot->working); /* line 208 */ [/code] Before this change, if burst was not a multiple of quantum you would be an infinite loop, as you did.

Member Avatar for histrungalot
0
3K

The End.