C :: Masking A Bit String Of Unknown Size

Mar 2, 2015

I have an assignment where I am trying to get the frac bits of a IEEE number representation. The number of exp and frac bits are given as parameters from the main, but I am unsure what bit mask to use as a one-size-fits mask.

View 5 Replies


ADVERTISEMENT

C :: Reading Files Of Unknown Size

Jan 23, 2013

I want my program to be able to read text files in the format:

number number
number number
number number...

and so on, so there are two columns of values. The problem I'm having is, there are a lot of numbers in the file, and it can vary. The program needs to read the numbers, put one column into one array, and the other in another, perform some operations on it all, and eventually pop out two different arrays. In other words, after I've got these arrays, I don't need them for much longer. I was hoping I could dynamically allocated some arrays to store the numbers and just free them as soon as I'm done with them.

If the file wasn't of such variable size or if it was guaranteed to be under a certain number of variables, I would have used:

Code:

while ( fscanf(input, "%lf %lf
", &col_1[], &col_2[]) == 2 )
{
no_rows++;
}

The problem is I want to allocate "no_rows" as the array size, which I don't have until after I have read the file.

View 9 Replies View Related

C++ ::  split String (unknown Length)

Mar 27, 2013

I manage to split this str = "abc,def,123"

to s1 = "abc", s2 = "def", s3 = "123" with this piece of code using find and substr.

string str, s1, s2, s3;
getline(cin, str);
unsigned pos1 = str.find(",");

[Code] ....

But what should I do if the len of the string is unknown ?

For example, str = "abc,def,123,ghi,jkl,456,mno" and so on...

View 4 Replies View Related

C/C++ :: How To Define String Of Unknown Length

Mar 7, 2014

how to define a string of undefined length in c programming?

View 1 Replies View Related

C++ :: Passing Unknown Arguments To Unknown Function

May 1, 2013

So I'm making setTimeout and setInterval functions.

I have this remember function (that is part of Timing class) which takes a function pointer and a void pointer, which are remembered in that object.

Another (timing) function of that object is called in every loop of the program and when specific time passes that function calls the remembered function whit the remembered void pointer as argument.

The problem is that the functions that need to be called require unknown multiple parameters, so what I need to do is make a new class that will store the needed arguments. I make the function that needs to be called and that storage object and pass pointers to them to my remember function, when the remembered function is called it stores the data from storage object in new variables and dose it's thing.

View 3 Replies View Related

C++ :: Read A String Of Unknown Length From Stdin

Oct 10, 2014

I want to read a string of unknown length from stdin. I tried to follow the approach from this link. URL....My code is like this:

#include <iostream>
#include <string>
using namespace std;
int n;
cin >> n;
cout << "The value of n is " << n << endl;
}

[code]......

What I have noticed is that if I take integer input from cin (cin >> n;) in the above code before getline, the control does not stop on getline to take str as input from the console. If I don't do (cin >> n) before getline then the control stops on getline and takes the string as input.What is the best way to read from console multiple strings of unknown length in combination with the integers?

View 5 Replies View Related

C++ :: Masking And Attempts On Password

Sep 9, 2013

Ive been working on a program that can mask the password and has 3 attempts. So far I can't do both at the same time. Here is my work. How can I do both?

#include<iostream>
#include<string.h>
#include<conio.h>
using namespace std;
int main() {
string _pass;
char input;

[Code] .....

View 3 Replies View Related

Visual C++ :: Retrieving Size Of Each String In Order To Produce A New Buffer For Concatenated String

Feb 25, 2013

What is the efficiency of the two assignments (line 1 and 2), i.e. (function calls, number of copies made, etc), also the Big O notation. I know there are function calls for retrieving the size of each string in order to produce a new buffer for the concatenated string...any difference between line 1 and 2 in terms of efficiency?

String s("Hello");
String t("There");
1. s = s + t;
2. s += t;

View 3 Replies View Related

C/C++ :: String Getting Printed Even After Size Of Array Is Exceeded?

Mar 4, 2015

#include<iostream.h>
#include<conio.h>
void main() {
clrscr();
char name[5];
cout<<"Enter your name";
cin>>name;
cout<<"Your name is"<<name;
getch();
}

In the above program the size of the array of the variable name is 5. which means the variable cant store more than 5 characters.

which also means

If I give the string "LINISH"
It should only print LINIS

But while the program is running, Even if I type a 10 characters string, It is getting printed Completely..why?

#include<iostream.h>
#include<conio.h>
void main(){
clrscr();
char name[5];

[Code] .....

In this program when I input a string for the variable name,It is getting printed completely, irrespective how many characters are there in the string.But If the string (which is input to the second variable that is game )holds more than 5 characters. the input of the first variable(name) is getting disturbed..why?

look at the below cited output to be more clear about my doubts.

OUTPUT NO:1

Enter your name:LINISHFRANCIS (Note that the input holds more than five chars)
Enter your game:GOLF(input is less than five chars)

LINISHFRANCIS loves GOLF(Two inputs are getting printed comopletely)

OUTPUT NO:

Enter your name:LINISHFRANCIS (Note that the input holds more than five chars)
Enter your game:FOOTBALL(input is more than five chars)

ALL loves FOOTBALL [Note that "ALL" is the last three letters of FOOTBALL

I am using TurboC++ for windows 7

View 5 Replies View Related

C++ :: Function To Return String - File Size

Feb 24, 2012

Where i can get ready function, which return string, which describe size of file?

For example
4 = 4 b
1045 = 1,01 Kb
and etc.

View 3 Replies View Related

C++ :: Limit Size Of String (arrays And C-style Strings)

Dec 9, 2014

how do I tell the if statement to output this error message 'exceeded the maximum amount of characters' that has its characters stored in an array using c-style string?

[INPUT] The cat caught the mouse!
[OUTPUT] Exceeded the maximum amount of characters (max 10)
#include<iostream>
#include<string>

[Code]....

View 2 Replies View Related

C++ :: Initialize String Data Members As Nullptr Or As Zero-size Array?

Nov 4, 2014

Is it generally better to initialize string data members as nullptr or as a zero-size array?

I can understand the former is superior from a memory-use perspective and also not requiring the extra allocation step. However, many string management functions will throw an exception - wcslen for instance - if you pass them a null pointer. Therefore I am finding any performance gained is somewhat wiped out by the extra if(pstString==nullptr) guards I have to use where it is possible a wchar_* may still be at null when the function is called.

View 4 Replies View Related

Visual C++ :: Change Frame Window Size According To Increase In Font Size

Nov 27, 2012

Change the frame window size according to font size increases.

View 3 Replies View Related

Visual C++ :: Text Size In Screen Is Different From Size In Print Preview?

Feb 1, 2013

I must take an old MFC project in VC++ 6.0 and make changes.

The problem is text size in screen is different from size in print preview.

for example with this font

Code:
CFont f50;
f50.CreateFont(100,0,0,0,FW_BOLD,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE,"Frutiger LT Std 45 Light");

And this text

Code:
s=_T("Let's try to calculate the size of this text");

and with MM_LOMETRIC map mode

GetTextExtent() returns me:

On screen: (1595,99)
Ink printer + print preview: (1589,100)
PDFCreator + print preview: (1580,100)

comparing with screen size the height is bigger but lenght is smaller. I don't understand.

I can understand that different printers process the fonts in different way and then to have different lenghts. That's not the problem. The problem is I need to simulate in screen the same behaviour i will have on printer because these texts are being aligned in the document, and I don't want to see that the text si aligned different in text than in paper.

What can I do to render the text on screen with the same size I will have on the printer? Print preview is doing it. Should I change the font parameters? is something related with pixels per inch?

View 4 Replies View Related

C++ :: Matrix With Unknown Dimension?

Feb 18, 2014

I try to write code for one problem which is worked with the matrix.I have written in specific size 5 by 5 and I know the general formula for these matrix based on dimension,I want to write a general form that take the matrix size and then create my favor matrix.However,when I write like below the following error is appeared

int m;
cin>>m;
int A[m][m];

Error: m must be constant

View 2 Replies View Related

C/C++ :: Unknown Type Name PGconn

Feb 27, 2015

I have the following code

#include <stdio.h>
#include <stdlib.h>
#include <postgresql/libpq-fe.h>

[Code].....

View 2 Replies View Related

C++ :: Cin And Unknown Number Of Integers

Dec 2, 2012

i dont usually write console programs, and i cant seem to find out how one parses an unknown number of arguments with cin.

the program receives an unknown amount of integers in stdin, and i need to parse them withouth hanging.

Unfortunately, stdin is a async. stream and blocks, if it doesnt find any integers left.

I cant use peek() or seek() either, as both are async, too, (which makes me wonder what their exact use is?).

View 3 Replies View Related

C :: Warning - Unknown Escape Sequence

Feb 2, 2013

I'm doing some file input/output work here in C and received this warning during compilation (GCC). My research indicates that this error is in response to white space or a character cancellation function or something like that. I'm not 100% sure exactly what it means. My code works fine, but the following warning does appear.

Code:
warning: unknown escape sequence: '40'

Here's my code (excluding a bunch of comments at the bottom of the file).

Code:
#include <stdio.h>
int main(void){
FILE *file;
file = fopen("Running Practice.c", "a");
fprintf(file, "Testing...
");
fclose(file);
}

I believe the error I received has to do with either the ' ' I used when appending text to my file, or something to do with there being a space in the file name itself.

View 6 Replies View Related

C :: How To Save Returned Of Unknown Length

Sep 15, 2014

I call a function that returns a string, and I can print it out fine, but I want to test the result of the function to see if it returns 0. But I can't just call the function again (GetNextToken(b)) because it will generate a different token. I can't allocate space for the string because I'm not sure what the size of the returned string is going to be.

Basically I want to see if the GetNextToken(b) returns 0, and if it doesn't then print the string. And running GetNextToken(b) again will give a different result.

Code:
int main(int argc, char **argv) {
SomeStruct* b = CreateStruct(argv[1],argv[2]);
printf("HERE %s", GetNextToken(b));

View 3 Replies View Related

C++ :: How To Use Multidimensional Array With Unknown Bounds

Feb 11, 2013

void printMatrix(int x[][]){
cout << "Matrix " << x << ":" << endl;
for(int r=0;r<rows;r++){
for(int c=0;c<colums;c++){
cout << x[r][c] << " ";
} cout << endl;
}
}

Error: declaration of 'x' as multidimensional array must have bounds for all dimensions except the first

How can i use multidimensional array with unknown bounds?

View 1 Replies View Related

C :: Why Size Of Struct Is Larger Than Sum Of All Size Of Its Members

Jul 11, 2013

I was wondering why, in C, the sizeof of a struct is larger than the the sum of all the sizeofs of it's members. It only seems to be by a few bytes, but as a bit of a perfectionist I fine this a bit annoying.

View 1 Replies View Related

C++ :: Writing Calculations For Unknown Amount Of Students?

Jun 27, 2014

I need to create a program that continuously records data until the user enters '0'

The data that I read in is the student's last name, the year of the student (1-4), the major, the gpa, and the advisors name. I then need to print out how many students are in each year (1-4), the number of students each advisor has, the average gpa for each major, and so on. This is what I have, but I am stuck and think that I might be headed the wrong direction because the only thing working is the loop (not my gpa test calc).

//This program displays information pertaining to students
#include <iostream>
#include <string>
using namespace std;
int main () {
int studYear;
double average, studGpa;
string studName, studMajor, studAdvisor, complete;

[code]....

View 2 Replies View Related

C/C++ :: Unknown Type Error For Bool Keyword

Jun 24, 2014

Is the bool keyword in C exactly like the boolean keyword in Java? why this code is getting an 'unknown type error' when I initiialze looping.

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

[Code].....

If I am completely using the boolean concept wrong in C, should I just use break statements instead?

View 11 Replies View Related

C/C++ :: Reading Unknown Number Of Integers In A Line?

Mar 1, 2015

I have a file with such a format:

string string 8 7 2
string string 7 12 19 -4
string string 1

As you can see I don't know how many numbers there are at the end. I have this code now:

while(!in.eof()) {
kr = 0;
getline(in, pavard, ','); getline(in, vard, ','); getline(in, gr, ',');
while(in.peek()) {
in >> k;
kr += k;
}
in.ignore();
}
in.close();

I tried various combinations with peek() function, but nothing worked.

View 2 Replies View Related

C/C++ :: Output Of Program Shows Unknown Character When It Run

Mar 20, 2014

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
float CalcPriceMember1(int,float&,int&);
float CalcPriceMember2(int,float&,int&);
float CalcPriceNonMember1(int,float&,int&);
float CalcPriceNonMember2(int,float&,int&);

[code].....

View 8 Replies View Related

C++ :: Tile Map (unknown Reason For Unresolved External Symbols)

Nov 7, 2013

So I tried to make a tile map function to display my map as tiles. I keep getting unresolved external symbol errors, I've included the header file, and used every declaration in it, but to be completely honest this is mostly just a try to see if I could do it, and so far I'm failing. So if you can see why I'm getting the error.

header tileMap.h:

#include<SFML/Graphics.hpp>
#include<iostream>
#include<fstream>
#include<string>
#include<cctype>
#include<vector>

class tileMap{

[Code] .....

output message:
1234567891011121314
1
1> main.cpp
1>c:users wiggystardustdocumentsvisual studio 2010projects ilemapenginemain.cpp(21): warning C4018: '<' : signed/unsigned mismatch

[Code] ....

View 8 Replies View Related







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