C :: Mod Function Not Working

Nov 27, 2013

Code:
#include <stdio.h>
int main() {
int m,c;

for(c=0;c<100;c++) {
m = c % 10;
printf("%d ",m);
}
return(0);
}

When I run this code in my compiler, I get the first nine or ten numbers, and then after that it just spells out the letters in my name in different sequences over and over.

View 3 Replies


ADVERTISEMENT

C++ :: Calling Another Function Within A Function Not Working

Feb 20, 2013

I have two functions bool check_key(string cKey, string eKey) and bool check_digit(char digit1, char digit2), and I have declared both of them globally (is this the right terminology?) right after the "using namespace std;" and right before the "int main(){".

In the first one, I called the second one . But it is giving me the error: "no match for call to `(std::string) (int&)' ".

Code:
bool check_key(string cKey, string eKey) {
if(cKey!="" && eKey=="") return false;
if(cKey=="" && eKey=="") return true;
if(cKey=="" && eKey!="") return true;
if(cKey.length()!= eKey.length()) return false;
bool flag=true;

[Code] ....

View 2 Replies View Related

C :: Recursive Function Not Working

Nov 9, 2013

the functions checks if the word is a palindrome like"level" "madam" etc. but with input "dfdfdfdffdfd" my recursive function fails.

Code:

/* main.c - Created on: Nov 9, 2013 - Author: Kaj P. Madsen*/
#define MAX 100
#include <string.h>
#include <stdio.h>
int checkPalindrome(char checkString[MAX]);
int checkRecPalindrome(char checkString[MAX], int strLgt, int a);
}

[code]....

results from "dfdfdfdffdfd" added some print to see that its the variables a and strLgt not functioning properly

Code:

dfdfdfdffdfd.
The word is not a palindrome(iterative)
strLgt: 11 a: 0
a: d strLgt: dstrLgt: 10 a: 1
a: f strLgt: fstrLgt: 9 a: 2
a: d strLgt: dstrLgt: 8 a: 3
a: f strLgt: fstrLgt: 7 a: 4

The word is palindrome (recursive)

View 4 Replies View Related

C :: Rounding Function Not Working

Oct 12, 2013

Why the roundf function is not successfully rounding my numbers.

Code:
#include <stdio.h>
#include <math.h>
//function declarations
void CelToFah (int ctemp, int ftemp);

[Code]....

it produces a correct number when called, but it is not a rounded number, the roundf((float)cel) does nothing. I get the same number with and without it.

View 6 Replies View Related

C++ :: String Function Isn't Working?

Dec 6, 2014

The function Reverse does seem to work. Its supposed to take the words in a sentence and then reverse them. For example: "This is nice" to "Nice is this." When I type "This is nice" I get " niceniceis nice"

#include <iostream>
#include <string>
using namespace std;

[Code]....

View 1 Replies View Related

C++ :: Remove Function Not Working?

Jan 24, 2014

Below is my .h file and the code below that is my function that I'm having troubles with. Its suppose to take in a users topic and see if that topic exists, if it does exist then find the keyword, commentcompare will find where that keyword is and delete the comment. However its not deleting anything and its returning temp is NULL.

class comment //adds a comment
{
public:
comment(char * create_comment);

[Code]...

View 3 Replies View Related

C++ :: Function Call Is Not Working

Oct 15, 2013

i think my function call is not working and i dont know how to fix it. Basically i want it to output my getstudent function and once i get the information i want it to output with the displaystudent.

#include <iostream>
#include <string>
using namespace std;
void displayStudent(Student x) {
cout << x.first << ' ' << x.last << endl;
cout << x.id << endl;

[code]....

View 6 Replies View Related

C++ :: Delete Function Not Working?

Oct 9, 2014

making my delete function work. My program does compile but my delete function doesn't work. I haven't finished my last two functions because I am focusing on the delete but how to Sell a title and print the value of all sold titles would be nice as well.

#include <iostream>
#include <cstdlib>
#include <string>

[Code].....

View 2 Replies View Related

C/C++ :: Call To Function To Calculate Fx/f Is Not Working

Apr 23, 2014

I am writing a program where f is the frequency and the x has the values as well. Now I am calculating the mean which is summation fx divided by summation f. I have the two functions working correctly but the getmean function is not working. It suppose to divide fx/f . check the code below

#include <iostream>
using namespace std;
const int SIZE=5;
class statisticalOperator{

[Code]....

View 2 Replies View Related

C :: Concatenate Strings In Array (2D) - Function Not Working Right?

Sep 6, 2013

I have a function that concatenate the strings in an array(2D)

Ex 1: Sean Connery Micheal King James Wood

Result: SeanConnery MichealKing JamesWood ...

The concatenation function working correctly and displays correctly in the function. But if I make another function to display it, it shows this

Ex 2: SeanConnery Sean MichealKing Micheal JamesWood James..

It adds to first name. Why?

Code:
void Concatenation( char dest[200][13] ) {
// loop through and concatenation the strings
for(int i=0;i<200;i+=2) {
myStrCat(dest[i],dest[i+1]); // mystrcat is equalto strcat()

[Code] .....

View 4 Replies View Related

C++ :: Average Calculation Function Not Working As Expected To

Dec 16, 2013

[URL] ....

My calculation function will not work like i wanted it to. It gives me 0 or a crazy number.

this is the function here:
the entire code is on the link:

double calculations(data&avgs) //Calculates the students grade into a final grade
{
int avg1;
int avg2;
int avg3;
int lab1;

[Code] ....

View 12 Replies View Related

C :: Get Binary Number And Change Its Bits - Calling A Function Not Working

Apr 8, 2013

This code gets a binary number and change its bits. I have a problem with the "bits_up" function . Why this function not working?

Code:
#include <stdio.h>
#include <stdlib.h>
int bits_up(uint first,uint last,int *ptr);
int main(void)
{
uint first,last,bitUD;
int InputBinNumber[4],updatedNum[4];

[Code] ....

View 5 Replies View Related

C++ :: Count Function In Program Not Working Properly - Counting Blank Nodes

May 9, 2013

I tested my count funtion. So my count function is not working properly, it should return 5 because 5 words have prefix "tal," but it is giving me 10. It's counting blank nodes.

This is my main.cpp file

int main() {
string word;
cout<<"Enter a word"<<endl;
cin >> word;
string filename;

[Code] .....

View 9 Replies View Related

C++ ::  Class Safe Array Type Print Function Not Working When Called

Oct 22, 2013

I've created a function where you can choose any bounds for an array based list (positive or negative, as long as the first position is smaller than the last position). However for some reason when I call the print() function in my application program it doesn't do anything. My print function is technically correct (I still have work to do on the output) but I can't figure out why it wont show anything at all. Below is my header, implementation, and main program files, along with results from running the program.

Header File:

//safearrayType Header File
class safeArrayType {
public:
void print() const;
void insertAt(int location, const int& insertItem);
safeArrayType(int firstPlace=0, int maxPlace = 100);

[Code] ....

ResultsEnter the first bound of yourlist: -3(this was my input)
Enter the last bound of yourlist: 7(this was my input)

Press any key to continue...

View 1 Replies View Related

C++ :: G++ / Why Is -L Not Working

Mar 6, 2015

Whenever I put my dll files in the same directory as my main.cpp and use this code, Code: g++ main.cpp -L. -lMyDll it works.

but if my dll files are in the other directory, Code: g++ main.cpp -L/myDlls -lMyDll it won't work. Why is this not working?

View 6 Replies View Related

C :: Get SDL Working

Jul 5, 2014

i am currently trying to get SDL working with C language.I am using Cygwin and Sublime text 2.I know and understand general programming, however i am trying to understand how to get SDL working with a file i create i.e test.c. i know to include which i have downloaded

#include <SDL.h>

where do i add the libraries so that i can use them in my program?

View 9 Replies View Related

C++ :: Irc Bot Not Working?

Apr 16, 2014

I am writing an irc bot in c++ on linux mint, and its not connecting right for some reason. anyways, heres the link: [URL].... . it was connecting to quakenet before I added the functions, but now it just says connecting... and then quits.

View 12 Replies View Related

C++ :: Irc Bot Not Working

Apr 3, 2013

I'm learning network programming and I've decided to program a simple c++ irc bot. I'm able to connect to server and send commands. But when I try to receive and show message from server I first get a few lines, like "Please, wait, while we process your connection" or "Found your hostname". And then I start to get a ton of information about the server. Here is the whole class:

header file:

#pragma once
#include <WinSock2.h>
#include <WS2tcpip.h>
class bot {
public:
bot(char *_server, char *_port);
~bot(void);

[Code] .....

Link to whole visual studio project: [URL] .... Am I doing something wrong during the IRC connection? Or I didn't understand how networking work?

View 19 Replies View Related

C++ :: Set Insert Not Working?

Jul 25, 2014

When inserting elements in a set it should only insert unique elements but I get duplicates too.

Code: #include <iostream> // cout
#include <algorithm> // unique, distance
#include <string>
#include <iterator> // std::back_inserter

[Code].....

View 3 Replies View Related

C :: If Statement Not Working

Oct 21, 2013

Well for some reason this doesn't work.

Code:

#include <stdio.h>#include <ctype.h>
int main(void)
{
int lottoNums[150];
int num;

[Code]....

View 13 Replies View Related

C :: Fclose Seems To Be Not Working

Mar 6, 2015

I'm trying to write a code that will

1) Generate a series of numbers
2) Write those numbers onto a txt file and
3) Read only the odd numbers out of the txt file.

I have 3 functions besides main that do each of the objectives individually and when separate they work just fine. But when I put them together for some reason the third function is never started. Also when I rearrange the 3rd function infront of the 2nd (since i have the txt file already saved) it works but I get an error when trying to close the txt file. It is the same close function that I'm using when first creating the txt file as well.

Here is the code

Code:

#include <stdio.h>
#include <stdlib.h>
int main()
}

[code]....

View 3 Replies View Related

C :: Working With Equations

Nov 19, 2013

I need to find out all the possible equations which are same of a given equation. For eg. a+b+c-d and b+c+a-d are same. So if the user inputs a+b+c-d then the output will be all the possible equations that can be formed from the given equation, viz:

a+c+b-d
c+a+b-d
-d+a+c+b

etc

i.e the program should rearrange the operands and operators in such a way that it should give the same result.

View 5 Replies View Related

C++ :: Working On 2 Axis The Same Way

Aug 13, 2013

I have been coding this 2D physic engine for quite some time, I work on the many part of these 2 axis ( x and y ) in the same manner is just that one is an x and one is y

So there is a lot of duplicate code

If there is a bug in one part I have to fix the other axis too which becomes a hazzle because I have to fix the duplicates too. The sample code from my program

for( auto it =bodies.begin(); it != bodies.end(); ++ it ){
sf::Vector2f velocity = it->getVelocity();
if( velocity.x != 0 ){
// do some friction force calculation

[Code] ...

It is even more of a hazzle when I work with 4 quadrant, I have 4 duplicate code each ... How do I write a function for both axis ?

View 9 Replies View Related

C/C++ :: SDL App Not Working On Other Computers

Jun 2, 2013

My SDL app which i made in visual c++ works properly on my pc, but it does not even starts on other computers. I have pasted all the required .dll files in my debug folder along with the pictures and sounds.

View 4 Replies View Related

C++ :: Case Statement Not Working?

Mar 6, 2015

I have this case statement that is not performing as expected. For some reason ASE_OK and ASE_NotPresent both print out. Why is this? ASE_OK is a return value of 0 while ASE_NotPresent is -1.

Code: // Try to create the buffers and store it
switch (theAsioDriver->createBuffers(info, numChannels, bufferSize, callbacksInfo)) {
case ASE_OK:
std::cout << "ASE_OK";
input->bufferSize = output->bufferSize = bufferSize; // Buffer size is stored in both input and output
case ASE_NotPresent:
std::cout << "ASE_NotPresent";
errorMessage = "Could not find input or output devices.";
return NO_DEVICES_FOUND;

[code]....

View 3 Replies View Related

C++ :: Eight Queens Program Not Working?

Feb 3, 2015

I'm a bit stuck on a program that prints out a 8x8 chessboard and Q to represent queens where the user enters input. The intended output is: Code: Enter the columns containing queens, in order by row: 0 3 4 0 0 7 6 7

Q.......
...Q....
....Q...
Q.......
Q.......
.......Q
......Q.
.......Q

but instead I get Code: Enter the columns containing queens, in order by row: 0 3 4 0 0 7 6 7

.Q
.Q
.Q
.Q
.Q
.Q

[code].....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved