C++ :: Print Conversion Specifiers To A Single Value Multiple

Oct 4, 2013

Is it possible to apply Print Conversion Specifiers to a single value multiple .

simply put ,

printf("%.1s%6lf
", perimeter_Circle);

I want one digit precision and 7 tab space on this item.

View 1 Replies


ADVERTISEMENT

C/C++ :: Single Facility Layout (multiple FOR Loops)

Mar 15, 2015

I've been given an assignment called a Single Facility Layout Problem in which a number of machines (for the purpose of the assignment they're called machines) with an x-coordinate, y-coordinate and weighting are given/inputted. I'm using 5 machines for ease of use and reading errors.

The object of the program is to calculate the value of each set of coordinates using the Me formula, the lower the value, the better. Thus the program should output a 5 different values.

Problem: My problem is that instead of getting, say 5 unique values, I'm getting 5 of the same value much like the photo attached.

- How can I remedy this?
- Is there a limit to the amount of FOR loops that can be nested? If not why isn't my code working correctly?
- Where should I place the printf statement in order that I will output 5 unique values?

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
//'h' is number of machines, objects etc.
int h=5;

[Code] .....

View 3 Replies View Related

C++ :: Processing Multiple Files From Single Directory?

Feb 21, 2012

I've tried to form together the following code so that I can process multiple files from one user specified directory. However, when I run the program it works great for the first file, but all other files are blank. The problem starts on the following line:

while(FileIn.good())

//---------------------------------------------------
#include <fstream>
#include <iostream>
#include <dirent.h>
#include <sys/stat.h>
using namespace std;
struct dirent *dirp;

[code]....

View 14 Replies View Related

C++ :: Strings - Read Multiple Values In On A Single Line

Jul 28, 2014

My question is on c++ strings. At the moment my program is reading input in one line at a time after the user presses enter.

I want to read multiple values in on a single line. Example: "apple banana orange end" ... How would I do this?

MAIN Code:
#include "Header.h"
#include "Orange.h"
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

[Code] ......

View 11 Replies View Related

C++ :: Compile Multiple Programs Stored Under A Single Project

Feb 21, 2015

I have started using code::blocks for practicing ,(was using bloodshed dev C++ til now). The thing is that m not able to compile multiple programs stored under a single project , as i have created project by the name of a topic and have decided to solve all problems related to that topic under that project.

When there was only one .cpp file in the project it compiled successfully ,but as soon as i created a second file and compiled it it says "main can be declared only once"

View 1 Replies View Related

C++ :: Print Numbers At Random From A Set Using Single Statement

Jan 21, 2012

I have an exercise that asks me to print numbers at random from the following set (using only a single statement):

2, 4, 6, 8, 10

Here's my statement:

Code:
cout << (2 + rand() % 9) << " ";

which prints numbers at random between 2 and 10, now I can use the modulus operator in an if...else statement to print only even numbers but the exercise specifically requires using only one statement, can that be done using the conditional operator? and if not then how?

View 10 Replies View Related

C Sharp :: Displaying Values In Multiple Textboxes Using Single SQL Command

Apr 23, 2012

I've a html table in my web form which contains 30 rows of textboxes. I want to display all the textbox values by using a search command...

View 1 Replies View Related

C# :: Multiple Tables Conversion From Excel XLS File To XML With OpenXML

Apr 25, 2014

I have downloaded this project from here -->> [URL] ....

This one works fine and it's a great commented code to understand even for beginners like myself, but it only works with one table per sheet. Once I add second table in sheet, it throws an error that something is wrong in one of the columns in my spreadsheet: It says: " Error occurs! The error message is: Cannot find column 4. "

Basically, I have this type of tables in my spreadsheet:

So I want that my program would export those two tables in a single .XML file (just read them both). And those two tables should be separated in two XML childs: the upper one should be Order-Header and the lower one - Line-Items, like this:

<ROOT>
<Order-Header>
.....
</Order-Header>
<Line-Items>
.....
</Line-Items>
</ROOT>
ConvertExcelToXML.cs:

[Code] ....

I copied all the code because I think it is the easier way to spot where to change it, to read those two tables in one spreadsheet and export them both in one XML file. How could I achieve this kind of functionality.

View 14 Replies View Related

C/C++ :: Print Single Linked List Backward With Functions / Classes - Error Message Regarding Header Files

Oct 11, 2014

I'm trying to print a single linked list backward with functions/classes. I have created the main file and 3 header files. But I'm getting an error on one of the header files, linkedListIterator after adding #include "linkedListType.h". It says that "linkedLlistType.h" is calling itself. And when I try to run it, I get an error of "too many header files." I have tried changing the headers many times, but nothing seems to work.

.cpp file:

/*(Printing a single linked list backward) Include the functions reversePrint and recursiveReversePrint, as discussed in this chapter, in the class linkedListType. Also, write a program function to print a (single) linked list backward. (Use either the class unorderedLinkedList or the class orderedLinkedList to test your function.)*/

#include "linkedListType.h"
#include "orderedLinkedList.h"
#include "linkedListIterator.h"
#include <iostream>
using namespace std;
struct nodeType

[Code] ....

header files:
[URL] .... (error in this header file)
[URL] ....

View 9 Replies View Related

C++ :: Some Error With Inheritance Access Specifiers

Aug 5, 2013

let me show you the (simple) code:

Code:
#ifndef DUCK_H_
#define DUCK_H_
#include<iostream>
using namespace std;
class Duck

[Code].....

When I compile, it says: "error: 'virtual void Duck::display()' is protected" how come I can't gain access to MallardDuck's display(), which is public?

View 3 Replies View Related

C/C++ :: Storage Class Specifiers Concept?

Feb 15, 2013

Write a program using all storage class specifiers?

View 2 Replies View Related

C++ :: Error - Two Or More Data Types In Declaration Specifiers

Nov 24, 2014

i have the following error defines.h:14:23: error: two or more data types in declaration specifiers, the begining define.h source code is (the line 14 is in red):

Code:
/* $Id: defines.h 3492 2011-09-18 20:44:09Z nekral-guest $ */
/* some useful defines */
#ifndef _DEFINES_H_
#define _DEFINES_H_

[Code]....

View 8 Replies View Related

C :: Print Multiple Characters To Same File Using Fprintf Function

Nov 5, 2014

I'm new to C and was wondering if it was possible to print multiple characters to the same file using the fprintf function provided in one of the C standard libraries?

View 1 Replies View Related

C# :: Multiple Desktop Display (Multiple Explorer Windows)

Jul 31, 2014

I want to develop an application which can host multiple views of explorer (window), where as each window is totally separate from others. So that I can have multiple desktop views through my single explorer. Any built in feature in .NET ?

View 11 Replies View Related

C/C++ :: How To Make Multiple Subroutine And Return Multiple Arrays

Aug 17, 2014

how to make subroutines and return multiple arrays.Before that, i wrote my program on matlab. could my program to be structured as following?

<header>
initial value of program;
subroutine1() {
calculating the first work;
return 2 or 3 arrays;

[code].....

View 14 Replies View Related

C :: Redirecting Multiple Pipes With Multiple Children

Mar 21, 2014

I've been working on a function that works like a pipeline of a shell but receives a directory, go over it an search for every file to send it to a filter, something like this in bash "cat dir/* | cmd_1 | cmd_2 | ... | cmd_N", The only problem i have with the code is the redirection of the pipe descriptors.

Code:

int main(int argc, char* argv[]){
char** cmd;
int Number_cmd;
cmd = &(argv[2]); /*list of cmds*/
Number_cmd = argc-2; /*number of cmds*/
}

[code]....

The code is seems to work fine except when i run it with more than one command in example ("./filter DIR wc rev") in this case it returns

wc: standard input: Bad file descriptor
wc: -: Bad file descriptor
0 0 0

View 2 Replies View Related

C++ ::  Multiple Files Causes (Multiple Definition) Error?

Jul 15, 2013

I'm using multiple C++ files in one project for the first time. Both have need to include a protected (#ifndef) header file. However, when I do that, I get a multiple definition error.

From what I found from research, adding the word inline before the function fixes the error. Is this the right way to do this, and why does it work? Should I make a habbit of just declaring any function that might be used in two .cpp files as inline?

View 5 Replies View Related

C++ :: Take Max Of Multiple Elements In Multiple Vectors?

Mar 1, 2012

Say I have 5 vectors of unsigned char each of size 5. I want to take the max of each index and store it in a new vector. What is the most optimal way to accomplish this?

My slow code:

Code:
vector<unsigned char> vec1;
vector<unsigned char> vec2;
vector<unsigned char> vec3;
vector<unsigned char> vec4;

[Code]....

View 3 Replies View Related

C++ :: Two Loops To Single Loop?

Jan 16, 2013

i have two loops ie.

if (n==null)
{
do loop 1
}
else //(n=!null)
{
do loop2
}

now i have to update the above code, with a single loop ie. when n==null or n!=null do the loop 1

how can i update.?

can i do like this
if(n==null ||n=!null)
{
do loop 1
}

is || operator above does the job what i expected

View 4 Replies View Related

C++ :: 2 For Loops In A Single Program?

Sep 15, 2013

I have to make my program display days 1-30 along side numbers increasing by 5 each day beginning with 6 on the first day. I wrote 2 for loops on separate tabs but now I want to know if its possible to combine them into 1.

For loop 1
int day,;
for (day = 1; day <=30; day = day + 1)

For loop 2
int candy;
for (int candy = 6; candy <=151; candy = candy +5)

View 10 Replies View Related

C :: Won't Print Numbers Sorted When Use Print Function

Nov 17, 2013

I am making a program where the user enters numbers into an array and then a number,x. The array is sorted, then x is inserted into the appropriate place. I wrote my selection sort

Code:

void Sort(int ary[], int size)
{
int temp;
int smallest;
int current;
int move;
}

[code]....

put it wont print the numbers sorted when I use my print function, just the unsorted numbers.

View 1 Replies View Related

C/C++ :: Using Print Statement To Print Certain Number Of Spaces

Sep 1, 2014

is there a to use printf to print certain number of blank spaces, where the number is derived from the output of a function?

for(m=low; m<=high;m++)
{
printf("t=%2d %'f(m)-1's %3c", m, ' ',*);
}

This is suppose to output

t=-3 *
t=-2 *
t=-1
.
.
.

View 2 Replies View Related

C :: Create Makefile For A Single File

May 20, 2013

I'm trying to create a Makefile for a single fie ( mycod.c)

What is the syntax?

View 2 Replies View Related

C :: Program That Uses A Single Thread And Is SLOW

Aug 27, 2013

I am writing a program, the trouble is is that it uses a single thread and is SLOW.

View 10 Replies View Related

C :: Copy Every Single Character From One Char Into Another

Jun 5, 2013

I have some problems with copying a single character from one char into another. How do I do that? Here is the function I am using

Code:

void
text_col (char line[]) {
char line1[1];
int l, ii;
l = strlen(line);

[Code] ....

I am trying to copy in a loop every single character from char line into char line1. That is not working.

View 8 Replies View Related

C# :: Draw Single Pixel On Window

Mar 27, 2014

Im new to c#. In c++ I have made a window and painted it with dots and concentric circles, like a radar PPI screen. Trying to do this in c#, I can't find how to draw a single pixel on the window.

Also, what should I be drawing on: the form, panel, picturebox...?

View 2 Replies View Related







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