C :: Reading And Accepting Full Name

Feb 6, 2013

I am having trouble in reading my full name in just a single variable and some kind of authentication. this is my code by the way.

Code:

#include <stdio.h>
int main(void)
{
char NAME_MINE1[40];

void clrscr();
}

[code]....

if i enter my full name i will be able to go on to the next statement/command but when i put on some name (which is not mine) i will automatically get an error and exit the program.If i type "Qwerty You Tube" EXACTLY and not just the first string before the whitespace i will be able to proceed but when i enter "Qwerty Tube You" or "Qazse Qop Queen" i will get an error and the program will exit.

View 6 Replies


ADVERTISEMENT

C :: Reading Full Sentence From Stdin And FILE

Sep 12, 2014

I thought maybe there was something in C that could read full sentences from stdin

Code:
scanf("%100[^
]s", string);

But that's not working for me. so i came up with my own function and its not giving me the results i want. here is the function including the call from main:

Code:
/* * * * * * * * * * * * * *
* FROM MAIN *
* * * * * * * * * * * * * */
printf("
Adding a new part...
");
printf("Enter part name: ");
get_string(new_part.pname);

[Code] .....

/* * * * * * * * * * * * * * * * * * * * * * *
* UNDESIRED OUTPUT *
* * * * * * * * * * * * * * * * * * * * * * */
8newpart

Where is the eight coming from? i thought fpurge clear the buffer. Also, I'm trying to add spaces in between words... i thought maybe putting within the while loop but outside of the if statement string[length +1] = '' would work, but it doesn't. so i put it outside of the loop but that i knew that wouldnt work either.

Problem #2 is reading from a file.. so far i have the following code which reads everything perfectly except the .txt file has a new line character at the end and i think its reading it:

Code:
/* * * * * * * * * * * * * * * * *
* READS FROM FILE *
* * * * * * * * * * * * * * * * */

if(read_in != NULL)
{
while ((fgets(read_string, MAX_PARTS ,read_in) != NULL) && (array_position < MAX_PARTS))

[Code] ....

0 in stock i want it to stop after reading the ball bearings line. a lot of issues for one post, but all related to reading inputs so i put it all on one.

View 2 Replies View Related

C :: Code Not Accepting Fractions?

Dec 12, 2014

i recently started programming. i mean I've been exposed to programming for the first time about a week ago. I've been following the tutorial here and playing around with my own code. For some reason, this code works while receiving decimals but not fractions.

Code:

#include <stdio.h>
int main()
{
float kd;
float kd_2;
printf("Please enter your k/d
");
scanf("%f", &kd );
}

[code]....

View 7 Replies View Related

C++ :: Accepting Multiple Clients?

Apr 14, 2013

I'm still having troubles connecting multiple clients to my server.To break down what I have going:I have a server that is supposed to accept multiple clients.. Currently, It works with one person.While the server is running, One person is allowed to play the game (While connected to the server). If the server is down, the player cannot play (This shows that the server and client responde and work).

However, While the server is running and the client joins, the first player is allowed to play. Everyone else's window goes black and says "Not Responding" (Like any other game in which isn't working).While these players are in "Not Responding", It still says the client has connected onto the server (But they're not able to play?).My client code is working perfectly, But i'm having troubles accepting multiple clients onto my server.

#include <iostream>
#include <winsock2.h>
#include <vector>
#include <process.h>
#include "Included/pthread.h"
//Some things i'm using or will be using in the future

[code]......

I had set notes by things to tell what they do!

View 10 Replies View Related

C/C++ :: Accepting Input For Functions?

Apr 7, 2014

how would one Be able to accept input for a function, for example:

#include <iostream>
using namespace std;
int numSubtract (int x){
if (x==1)
return 1;
else
return numSubtract (x-1);
}
int main (){
cout << numSubtract (5) ;
}

how would I be able to have the user input their own number instead of 5 in this example, and then output that?

View 2 Replies View Related

C :: Prototype For A Function Accepting Variable Arguments

Dec 6, 2014

what should be the prototype for the following function.

Code:void addition(int x, ...);

I am getting compilation errors. I have written the prototype as :

Code: void addition(int, va_list);

View 3 Replies View Related

Visual C++ :: Winsock - Accepting Multiple Clients On A Server?

Jun 16, 2013

My problem is that I've created a Client and Server program in which they communicate. The Client is an SDL Application that allows you to play as a movable character IF YOU ARE CONNECTED TO THE SERVER. If not, You're unable to play. THIS WORKS!

However, Only one client is able to play on my server?? Anyone elses' window freezes and they are not allowed to play (As if not connected to the server). Here is my server code.

Code:
#include <iostream>
#include <winsock2.h>
#include <vector>
#include <process.h>
#include "Included/pthread.h"
#define MAX_THREADS 5
bool gamerunning = true;

[Code] ....

I'm having troubles allowing more than one client to play on the server.

View 2 Replies View Related

C++ :: Get Full Time Without Seconds

Jun 21, 2013

I have a code to check the last time modification of a file using "gmtime". Is it possible to remove the seconds in the result?

Here is my code:

struct tm* clock;// create a time structure
struct stat attrib;// create a file attribute structure
stat("test.txt", &attrib);// get the attributes of afile.txt
clock = gmtime(&(attrib.st_mtime));// Get the last modified time and put it into the time structure

View 6 Replies View Related

C++ :: Not Marking That The Queue Is Full

Apr 11, 2013

Why is this code not marking that the queue is full.. I'm just including my Add function that verifies if they want to add another number to the queue. The isFull function works fine, have used it on other programs.

template <class T> //Template currSize function
int Queue<T> :: currSize ()
{
return (rear - front + arraylength) % arraylength; //

[Code].....

The output goes all the way down to 1 spot left, lets the user enter the last element. Then it asks if they want to add another.. At this point, when they hit Y, it lets them add it and it says there are 5 spots left!

View 8 Replies View Related

C++ :: Getting Full Sentence To Input?

Oct 29, 2013

#include <iostream>
#include <string>
#include <istream>

[Code]....

It seems like my program doesnt want to take in a sentence, only the first word i type in

View 1 Replies View Related

C++ :: Get Full Path Of File?

Nov 26, 2013

I wanted to make my program read the file "input.txt". I did it successfully, but now I want to get the full path of the file "input.txt". Is there any way to do it?

My output should be :

FILE *file;
std::string fullFileName;
file = fopen("input.txt", "rb");
if(file != NULL)
{
// getfullfilename(file, fullFileName);
// std::cout << fullFileName.c_str() << std::endl;
}

View 5 Replies View Related

C++ ::  Getting A Full Path By Using Text File Name

Jan 16, 2014

How to get a full path of a directory only using a text file name? (Btw i am using visual studio not windows)...

View 9 Replies View Related

C/C++ :: How To Store Full Name In Two-dimensional Array

Nov 3, 2014

I'm trying to design a C program that ask the users to type their full name (seperate by a space), and store this name in a two dimensional array. I just want to test if I did it correctly, so i just entered one name and give it a try.

char name[50][2];
printf("enter the neame");
scanf("%s%s",&name[0][0],&name[0][1]);
printf("%s",name);
return 0;

but the program will not print the expected result.

View 4 Replies View Related

C++ :: Create A Pointer To A Full Text Line

Jun 3, 2013

It's really simple to say to a pointer to point to a sigle character or a single number.

Code: int *ptr;
int a = 5;
cout << *ptr << endl;

But I want for example a pointer to change a whole text line. My idea is that the user enters which language he speaks.

Code: cout << "English" << endl;
cout << "Swedish" << endl;

But I don't know how to this. I could have done this without pointers with if statments but I want to do it with pointers because it were a exercise to do.

View 3 Replies View Related

C++ :: Program To Emulate Full Screen Console

Dec 5, 2013

So, I'm making a program in C++ that emulates a full screen console... I used SetCurrentConsoleFontEx to set the font to 12x16 but it sucks...

Anyway, I read here: [URL] .... that also the console font can be changed, but I can't make it work! How can i set the font to Lucida Console? This is the function I use to change font size:

void setFontSize(int x, int y) {
PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx = new CONSOLE_FONT_INFOEX();
lpConsoleCurrentFontEx->cbSize = sizeof(CONSOLE_FONT_INFOEX);
GetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), NULL, lpConsoleCurrentFontEx);
lpConsoleCurrentFontEx->dwFontSize.X = x;
lpConsoleCurrentFontEx->dwFontSize.Y = y;
SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), NULL, lpConsoleCurrentFontEx);
}

View 2 Replies View Related

C++ :: Build Full Computer Algebra System?

Apr 1, 2013

Im trying to build a full computer algebra system in c++

View 1 Replies View Related

C/C++ :: Full Menu Not Shown When Running Program

Mar 4, 2014

The program is not showing my full menu just the 0 Exit and the last line of text. This is the full main source file (not implementation file or header file).

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;
struct menuItem{
string itemDesc;
double price;
int menuType;

[Code] .....

View 3 Replies View Related

Visual C++ :: Enter First And Surname And Then Display Full Name

Sep 21, 2012

I'am new to C++, program is : enter first and surname and then display the full name:

code below:

// Enter first and surname and then display the full name.
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

[Code] ....

View 10 Replies View Related

C++ :: Convert Full Word To Uppercase If It Is Lowercase In A String?

Feb 28, 2014

The problem I am facing is that I have to output the C++ input file and display every line of code in the output, except in the output I have to convert every if, else, and while as IF, ELSE, WHILE. I tackled the first part and now its onto the 'easier' part even t

View 1 Replies View Related

C++ :: Check If Binary Search Tree Is Full Or Not Recursively?

Dec 5, 2013

How would I check if a binary search tree is full or not recursively?? ?

View 1 Replies View Related

C Sharp :: Full Code For Webcam Alert Motion Detector?

Mar 12, 2013

i have webcam i need to make project when this webcam detect any motion in his spot give me alert ,,,

View 4 Replies View Related

C++ :: Program To Read Middle Names Within Text File - Full String Not Appearing

Oct 24, 2014

I've a problem here...

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>
#include <iomanip>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])

[Code] ....

The program needs to be able to read the middle names within the text file named Info2.txt

Simply adding the Mname or any related value where the other to name values doesn't do anything and only the 1st line appears on the output.

Don Jon111012
Jack Bo Todd151015
Jill Jo Jane161011
Bob Jack Chuck 131513
Da Fu111012

That is the correct way it appears in the text file. Also I know it's commented out, but that just to keep the program from crashing.

current output

Survey Results:

Name Results
Don Jon 33.00

This is the Info1.txt file info by the way.

Ken A202017
Gus B151015
Bill C151512
Jara C151720
Lu E101510
Chow B171015

And the output

Survey Results:

Name Results
Ken A 57.00
Gus B40.00
Bill C42.00
Jara C52.00
Lu E35.00
Chow B 42.00

Which when ran with Info1 selected, it is the correct output I'm looking for. I've tried getline and other solutions and they didn't work.

View 1 Replies View Related

Visual C++ :: How To Detect If Window Media Player Is Running In Full Screen Mode

Jan 21, 2013

How can I check if window media player is running in full screen mode & topmost in c++ MFC?

What I used is this logic:

I compared media player full screen coordinates to that of monitor coordinates.If they are same implies media player is in fullscreen.But it has one flaw.Whenever there are control(for play,pause) displayed in full screen in media player, coordinates are not coming same as that of monitor.

View 10 Replies View Related

C :: Reading JPG Metadata?

Nov 12, 2013

I am translating a MATLAB code into C and these are the lines

Code:
file_name = imageTest(i,: );
imgInfo = imfinfo(file_name);
IMAGE_1 = imread(file_name);
if strcmp(imgInfo.ColorType,'truecolor')

[Code].....

how I can change this code to C? I did search but I did not find anything related.

View 3 Replies View Related

C++ :: Files Reading From PDF?

Feb 26, 2013

How do I read a .pdf file using C++? When I try to open it using myfile.open ("example.pdf"); but all I see is some Crazy Symbols. Is there any way to open ?

View 3 Replies View Related

C++ :: Reading Information Off The Web?

Sep 9, 2013

I am building a program that will read from a particular web page. I have written it so that it will parse the page correctly, but I can only do it for a downloaded page right now. I would like for it to work simply with the URL.

I have seen things about "screen scraping", though I don't quite understand what it does - I think it's more for just parsing it, which I can already do.

If it is possible to automatically download that file, that is fine as well.

If it matters at all, the pages I am reading from are stories on Fanfiction.net.

View 1 Replies View Related







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