C/C++ :: Programming Variable Name Rules?

Nov 13, 2014

Where are the c programming variable name rules defined? I usually use these two websites for figuring out these kind of things but I don't see it anywhere.

[URL]

View 4 Replies


ADVERTISEMENT

Visual C++ :: Make Transition From Console Programming To GUI Programming?

Nov 30, 2013

my a book or website where I can make a transition from console programming to GUI programming. I'm totally confused about this. I know how to program in console and can make a whole program based on console. I also know the OPP programming, but it's clear that nobody uses console programming anymore.

View 10 Replies View Related

C++ :: Rules To Compare Two Strings Object

Sep 1, 2014

In my book I have the following example : Code:

std::string str = "Hello";
std::string phrase = "Hello world";
std::string slang = "Hiya"; and i have these two rules to compare 2 strings object :

if two strings have different lenghts and if every character in the shorter string is equal to the corresponding character of the longer string, than the shorter string is less than the longer string.

if any characters at corresponding positions of two strings differ, then the result of the string comparison is the result of comparing the first character at wich the strings differ then my book says : if we apply the rules of the comparison we know that phrase is greater than str( ok i've understood this ) and that slang is greater than both slang and phrase ( why ?)

explain me rule number two ? in phrase and slang the characters differ and the first character that differ is not H so why my book says slang is bigger than phrase ?

View 3 Replies View Related

C :: Read A Text File That Contains Permutation Rules

Mar 27, 2014

I have been given an assignment that has to do with permutations. I am suppose to read a text file that contains the permutation rules and the text to be "permutated", and then output the rules and the new text into an output file.

So far, I've gotten this:

Code:
# include <stdio.h>
void printArray(FILE* file, char* array, int maxSize)
{
int i;
for (i = 0; i<maxSize; i++)
fprintf(file, "%c", *(array + i));

[Code] ....

Here is what the input file looks like:

Code:
0 1 2 3 4 5 6 7 8 9
4 5 6 0 9 7 8 1 2 3

Moderation in temper, is always a virtue; but moderation in principle, is a species of vice.

Here is what the output file is suppose to look like:

Code:
0 1 2 3 4 5 6 7 8 9
4 5 6 0 9 7 8 1 2 3

ratMnioodetem rpein al,ywa isvirsetu a t m;eod
buon r inaticipp,lerina s cpeis of icvies - Temho.
-ainaPes

The first two lines are the permutation rules. Currently I have figured out how to read the file into an array and then print it back out into a text.

What I want to do is figure out how to read only the first two line of the input file and store that as a permutation rules, and then continue reading the rest of the input file and store that separately as the text to be "permutated". And then eventually figure out how to apply the permutation to the text.

View 3 Replies View Related

C++ :: Type Promotion Rules For Fixed Point Class

Jun 19, 2014

I've come across an interesting question involving a fixed-point arithmetic class.

Suppose I've got a template that implements a fixed-point quantity. It has two characteristics: width and number of fraction bits:

Code:
template <typename RAWTYPE, unsigned int FRACBITS>
class Fixed
{
....
};

So if I want a 32-bit value with 12 bits of fraction I can declare:

Code:
Fixed<int32_t, 12> x;

Suppose I've implemented a freestanding operator+() for fixed values, and I want to be able to add different types together:

Code:
template <typename RAWTYPE1, unsigned int FRACBITS1, typename RAWTYPE2, unsigned int FRACBITS2>
???? operator+(Fixed<RAWTYPE1, FRACBITS1> lhs, Fixed<RAWTYPE2, FRACBITS2> rhs)
{
???
}

What is the result type? Obviously, it's up to me to decide this. As reference, consider the type promotion rules for native types:

Code:
short a;
int b;
int result = a + b; In this case, the short value is promoted to the int value, and the addition happens on int.

It would seem a similar rule (go to the wider type) would be appropriate for fixed point. But there is another dimension to the problem, which is the number of fraction bits. Should you go to the wider type? Or the most precise type? Should you endeavor to minimize the number of bits which are discarded? What's the most intuitive rule?

View 10 Replies View Related

C++ :: Create Password Check Program That Makes Sure That Rules Are Followed

Feb 27, 2014

I am new to C++ and am stuck on a program. I've got to create a password check program that makes sure the password rules are followed. Below is the code and the rules i have typed in the comments at the beginning of the program. I have to use loops and cant use arrays for this.

#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
//Prompt user to entered a password to be tested
cout << "Password must be at least 8 characters long." << endl;

[Code] .....

View 2 Replies View Related

C :: Program That Queries User For A Noun And Forms Its Plural On The Basis Of Rules

Nov 13, 2014

I am having trouble with a program that queries the user for a noun and forms its plural on the basis of these rules:

a. If the noun ends in "y" remove the "y" and add "ies".
b. If the noun ends in "s", "ch", or "sh" add "es".
c. In all other cases, add "s".

I am having trouble getting started.

View 4 Replies View Related

C :: UDO Socket Programming

Dec 18, 2014

I am trying to test my client-server socket program wherein the client connects to the server,client sends a message, server receives it and echo back to the client.So far, in the program server receives the message from the client, prints it BUT when it tries to send the message back to the client it shows an error.

sendto(): Invalid argument.I am new to socket programming.

Code:

//Server
#include<stdio.h> //printf
#include<string.h> //memset
#include<stdlib.h> //exit(0)
#include<netinet/in.h>
#include<sys/socket.h>
#define BUFLEN 512 //Max length of buffer
#define PORT 10003 //The port on which to listen for incoming data
}

[code]....

View 3 Replies View Related

C :: Parallel Port Programming - On / Off LED

Sep 9, 2014

I try to ON and OFF the LED's via parallel port. I connect the cathode of LED's with pin number 18 that is ground and anode of each LED is connected through a 1K resistor to pin 2 to 8. I write the following programe

Code:
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#define PORTID 0x378
void main(){
outportb(PORTID,0x00);
getch()
}

But when i connect the LEDS to the parallel port all the LEDS are LIT while i also change the 0x00 to 0xff and so on. But no effect on the LED's.

View 8 Replies View Related

C :: How To Check Dates In Programming

Mar 6, 2015

I'm supposed to make a program that can tell which date, out of any number of dates entered by the user, is the earliest date. However, this is based off another program that I did not do in the last chapter. Since it's a pretty simple program to use as the base for the more "generalized" one, I decided to make the more basic one that can only take two dates, first. If it was just one integer, I could just use date1 for the first date and date2 for the second date, but each date uses 6-8 separate numbers.

how do I tell it something like, "if(date1 < date2)", with date1 and date2 including their month, day, and year. I could do a separate integer name/tag (I forgot what they're called) for each number, but that sounds like doing a lot more adding and subtracting, and like it could easily get messy.Should I, or can I, add all the numbers under the "date" together to see which date has the "lowest number" or "earliest date", or should I somehow handle each number, that is month, day, and year, separately?Here's the code so far:

Code:

include <stdio.h>int main(void)
{
int date1, date2;
printf("Enter first date (mm/dd/yy):
");
scanf("%d/%d/%d", &date1);
printf("Enter second date (mm/dd/yy):
}

[code]....

View 10 Replies View Related

C :: Socket Programming Getting Segfault

May 22, 2013

I am trying to send a packet across a client/server communication. I am getting a seg fault (while running the program(It compiles fine)) when I try to read the neighbor file, You should be able to see this below the comment /***** Read neighbor file***/ :

Code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
}

[code]....

View 2 Replies View Related

C++ :: Modular Programming With Template

May 16, 2014

I'm trying to create a stack of generic variable with template. This is the code.

BlockingStack.h
#include "stdafx.h"
#pragma once
template <class T>
class BlockingStack {
[Code] .....

I don't understand why ,but it dont work... It produce this errors:

1>Blocking_stack.obj : error LNK2019: riferimento al simbolo esterno "public: __thiscall BlockingStack<int>::BlockingStack<int>(int)" (??0?$BlockingStack@H@@QAE@H@Z) non risolto nella funzione _wmain
1>Blocking_stack.obj : error LNK2019: riferimento al simbolo esterno "public: __thiscall

[Code] ....

View 4 Replies View Related

C++ :: Can Be Used For Server Side Programming

Nov 28, 2013

I know this question must have been asked before, but the problem that I am facing is that I am using a library PoDoFo to parse PDF files. It seems that it is only compatible with C++.

Now I want the application to be web-based. That is, the user uploads a PDF file on the server, the server parses it and the parsed content is then sent back to the user.

Is such a thing possible with C++, or maybe any good work-arounds? Or should I look at server-side scripting languages like PHP and their respective libraries?

View 8 Replies View Related

C :: Programming - Using Strlen With Text File

Oct 13, 2014

I am trying to read all the 9 letter words in a words list text file and print them to the screen. Here is the code I have so far, but I am currently printing nothing.

Code:

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

[Code]....

View 7 Replies View Related

C :: Make Alphabet Soup On Programming

Mar 19, 2014

I'm trying to make an alphabet soup on C programming, and I'm stuck with a problem.I need to make a function able to automatically find all the words that exist in alphabet soup.

View 4 Replies View Related

C :: Circuit Diagram - Programming A Timer

Jan 29, 2014

I have attached a circuit diagram below, which has been tested. Currently you have to manually push the switch to change the brightness of the bulbs. I want to program a chip to automate this.

Over 90 days the chip will output a high signal in replace of the switch every set period of time (say once every 1.5days). I can use any chip but the smaller the better!

View 1 Replies View Related

C :: Socket Programming And Console Control

Jan 4, 2014

I would like to make a program for final project, which can let me send any file to my computer at home, and i can access any files in my computer when i am not at home.sending and getting file will be with socket programming.

i would like to reach all folders in computer, not only the folder, where client program exist. how can i access other folders at remote computer by using my program?

View 4 Replies View Related

C :: Array Getting Lost Probably Fundamentals Of Programming

Sep 7, 2014

why an array would lose its contents when I believe it shouldn't. Below is a skeleton program just to kind of show what seems to be happening. Basically I set up the delims array with just a star. The program runs a good number of times but at some point the delims array gets lost. My guess is the stack is overflowing or something? But it "appears" all other variables are ok (although I cant be sure).

I move the char delims into the while loop. What is this "actually" doing to the original delims variable ... are we wasting memory here (bearing in mind the original delims variable is sometimes loosing the string :/)

Code:

somefunction()
{
char delims[] = "*" ;
char *result = NULL ;
while (1)
}

[code]...

View 6 Replies View Related

C :: Sort Numbers In Order In Programming

Feb 19, 2014

Write a program that orders three double numbers by increasing value. The program should include a function named sort3 that takes three double * arguments (pointer to double). The function prototype is void sort3(double *x, double *y, double *z); The function should reorder the values pointed to by its arguments so that after the call sort3(&x, &y, &z); the numbers satisfy . Your program should input data and print results using the following format:

Enter three numbers: 4.7 1.4 3.2
The ordered sequence is: 1.4 3.2 4.7

And here is my program: C code - 32 lines - codepad

I am getting a lot of errors when I run it through GCC. I can only use pointers.

View 4 Replies View Related

C++ ::  Programming A Random Number Game

Nov 21, 2013

This is the code i have so far

#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

/* function main begins program execution */
int main() {

[Code] .....

I have gotten the conditions to execute properly but will end the program after doing a case instead of asking to play again and loop. Also how would i output the number of wins and losses?

View 2 Replies View Related

C++ :: 3D Graphics Programming Using SDL - Draw A Cube?

Apr 24, 2014

Ive been experimenting with 3d graphics by using SDL only and lines to draw 3d shapes (no OpenGL or extension libraries, just pure math),

Ive used this page mainly to guide me on perspective projection but i have no luck [URL] ....

Ive been trying to draw a cube, but instead it gives me a mirrored dual triangular pyramids

This code here rotates the object as seen from the equations in this link: [URL] ....

double aX, aY, aZ;
for ( i = 0; i < model->qLength; i++ ) {
for ( j = 0; j < 4; j++ ) {
aX = model->quadArr[i].pointArr[j].x;
aY = model->quadArr[i].pointArr[j].y;
aZ = model->quadArr[i].pointArr[j].z;

[Code] .....

generally, i project it onto a 2d plane using: [URL] .....

double dx, dy, dz, dX, dY, dZ;
int bx, by, bX, bY;
for ( i = 0; i < model->qLength; i++ ) {
for ( j = 0; j < 4; j++ ) {

[Code] .....

I understand that my code is very messy and unoptimized, but im just concentrating on getting the core concepts to work with my code

View 1 Replies View Related

C++ :: Vulnerable Recursive Programming On Define

May 20, 2013

I've been studying "algorithm" by myself by book. And there's this part - vulnerable point of "define" syntax on recursive programming.

Code:

int max_arr2(int arr[], int arr_len) {
int (arr_len == 1)
return arr[0];
else
return max(arr[arr_len-1], max_arr2(arr, arr_len-1);
.
.

This book says, " function 'max_arr2' is just recursive function, without any problem. but if max() is defined like this,

#define max(x,y) ((x)>(y) ? (x):(y))

and if array is just declined, it will take very long time."

I typed this code and run, and actually it really takes long time.

View 1 Replies View Related

C++ :: Finding Lowest Grade In Programming?

Aug 3, 2014

How to find a lowest grade in programing using the c++.

example: {65,89,100,76,80}.
#include<iostream>
using std::cout;
using std::endl;
int main() {
float grade=0;

[Code] .....

View 1 Replies View Related

C++ :: Client Server Programming Using TTcpServer?

Jun 23, 2013

I am using the following code that I copied from a website to send some numbers using TTcpServer in C++.

void __fastcall TForm2::Button1Click(TObject *Sender) {
//Creating a stream
std::auto_ptr<TMemoryStream> myStream(new TMemoryStream);
for (byte i = 0; i < 9; i++) {
myStream->WriteBuffer(&i,1);

[code]....

I do not understand what is being sent in the byte variable, nor why a byte variable was used. I want to send some strings instead of numbers, but I don't understand what's taking place so I can't identify what to change.

View 2 Replies View Related

C++ :: Audio Programming (wave Format)

May 31, 2012

I have problem with this code:

Code:
#include <string>
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
// multiplier
const double MULTIPLIER = 0.0000001;

[Code] .....

It should cut wav files into smaller pieces using text file .lab (the values multiplied by * 0.0000001 gives time in second. For example, i have such file with recorded yes and no: [URL] ..... and such boundaries [URL] .... It all should be in the same folder, then, after puting "yesno.wav" into command line and press enter it should gives 2 files with yes and no words. But it doesnt - i obtained one file with silent and one short sound. The record is recorded by Audacity, default sample rate 44100, default sample format 16-bit.

View 10 Replies View Related

C++ :: Implementation Of Linear Programming Solver

Sep 17, 2013

I am trying to implement the linear programming solver. This is the header file of the linear programming solver :

/*!
internal
Representation of a LP constraint like:
(c1 * X1) + (c2 * X2) + ... = K
or <= K
or >= K
Where (ci, Xi) are the pairs in "variables" and K the real "constant".
*/

[Code] .....

I want to parse all the constraints and bounds as inputs and get the maximum value of the objective function as the output using the above lpsolver header file. I have also attached the sample file below.

View 14 Replies View Related







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