C :: Simple Valid / Invalid Function - Determine Either A URL Address Is Correct Or Not

Jul 13, 2013

I have to write a code which would determine either a URL address is correct or not.

Now, a valid address should look like: "www.something.something.uk".

It has to have 3 dots, 3 w-s in the beginning, and it must end with "uk".

E.g.

Valid addresses:
1. www.jce.ac.uk
2. www.tr2213.oi34.uk

Invalid addresses:
1. www2.jce.ac.uk
2. òæøéàìé - îëììä à÷ãîéú ìäðãñä éøåùìéí - ìéîåãé äðãñä ìúåàø øàùåï
3. www.something.uk

Just to be clear, this criteria mentioned above is not real, just homework

Code:
#include <iostream>
#include <string.h>
using namespace std;
int isValid (char s[])
{
int dots=0;

[Code] ......

It tells me both strings are incorrect but the first 1 is.

View 4 Replies


ADVERTISEMENT

C :: Valid Email Address Check

Jul 13, 2013

Now I have to write a code which would determine whether an Email address is valid or not.

In my exercise a valid address should look like this : ___@___.___.il (___ for any letters)

E.g. Valid address:

something @ something . something . il Invalid: tami @ jce . ac . uk

(without spaces of course)

Code:
#include <iostream>
#include <string.h>
using namespace std;
int isValid (char s[]) {
int length=strlen(s), ind1=0, ind2=0;

[Code] ....

It doesn't work well. It says both addresses are wrong when the 1st one isn't.

View 9 Replies View Related

C++ :: Partly Recompilation Generates Invalid Address Fault?

Jun 1, 2013

I'm making an x86 emulator with C++ (currently 8086/80186 with some little unfound errors). When I'm compiling all the files (deleting all *.o files and running make), the emulator runs fine (still some errors, but it runs). When I run make, just having one file adjusted, the emulator (JPCSP, a PSP emulator) gives me an invalid opcode/address fault. The emulator does use some pointers at different places though (mostly dynamic memory and optimization), can this be the cause? Causing addressing errors with partial recompilation using make?

View 1 Replies View Related

C :: How To Determine If Modulus 16 Of A Pointer Address Equals 0

Mar 21, 2013

For part of my program in class I have to take a pointer address and determine if it is equal to 0 modulus 16. But I can't figure it out.

View 1 Replies View Related

C++ :: Delete Invalid Input Until Correct Input Is Entered?

Mar 20, 2014

Program is to add two fractions together like so..

This program adds fractions. ‘Y’ continues, any other key exits program
===================================================
Enter numerator 1 ==> 1
Enter denominator 1 ==> 3
Enter numerator 2 ==> 1
Enter denominator 2 ==> 6
1 1 1
--- + --- = ---
3 6 2
-----------------------------------------------------
Continue? Y or N! ==> n

My question is that i need each input to be a number.
if a character is entered i want it to output something like..

This program adds fractions. ‘Y’ continues, any other key exits program
===================================================
Enter numerator 1 ==> 1
Enter denominator 1 ==> a
You need to enter a number here.
Press any key to continue.

and then clear the part where the letter was entered.

This program adds fractions. ‘Y’ continues, any other key exits program
===================================================
Enter numerator 1 ==> 1
Enter denominator 1 ==>

View 5 Replies View Related

C :: Creating Simple Address Book Struct - For Loop?

May 11, 2014

My address book will be simple, and the thing's that I'm expecting to use in it are :

Pointers, Linked Lists
Malloc
Structs
Typedefs
Makefile, header file
Putting functions into different program files

I have started the program trying to create a struct, and getting it working with a couple of entries before going onto user input and splitting it up.

Code:

#include <stdio.h>
#include <stdlib.h>
int main(void) {
// Struct type address book. Just a name, a number and a pointer

[Code] .....

I'm a bit lost at this point... My knee jerk thought is to create a for loop, and cycle through the list.

I'm not sure how this would apply to this though? Without using the familiar type of print loop such as :

Code:
for (i = 0; ;i++) {
printf("%i
", array[i];
}

I'm thinking that I need to create a temporary struct that can be used to assign the value of the next struct in the list, and then somehow print from that....

I'll try and write the logic out :

while temp != NULL (The last node value is assigned NULL to show us where the end of the list is)

create a temporary pointer that can be used to keep track of where we are in the list.

print out the current entry name and number

then assign the temp pointer value to the * next of the current struct. So if we are in entry1 the *next should be the address of entry 2.

Print out entry 2 name and number, assign entry 2 next to the temp value.

View 1 Replies View Related

C++ :: Valid Function Prototypes?

Mar 11, 2013

I was asked by a friend about validity of following function prototypes,

void func1(int = 0, int*);
void func2(int = 1, int& = 2);
void func3(int*, int& = 3);
void func4(int& = 4, int* = 0);
void func5(int& = 0, int = 1);
void func6(int = 5, int& = 6, int* = 0);

I think the only prototype that is invalid is func1 because it does not have default parameter on the far right.

View 16 Replies View Related

C++ :: Invalid Storage Class For A Function?

Mar 23, 2014

I made a program and when I try to use the main driver to instantiate everything it says invalid storage class for a function. All of my code is in 4 separate files i'm just trying to get it to run now.

Code:
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <fstream>

[Code]......

View 1 Replies View Related

C++ :: Determine If A Function Has Been Defined

Apr 8, 2013

I would like to make a handler for input events, but not be required to define all the functions.For example, if I had

void mouseDown(int button,vec2 pos);
void mouseUp(int button,vec2 pos);
static void mouseStateHandle(int button,int state,int x,int y) {
switch(state){
case DOWN:

[code]....

in the 'mouseStateHandle' function? I don't know enough about C++ to be able to come up with a solution.

View 19 Replies View Related

C :: Modify Value Of Whole Array By Passing It To A Function - Invalid Lvalue Error

Sep 23, 2013

i want to modify value of whole array by passing it to a function and make each value of array multiplied by 3 ,return the value to main and print it using pointer.

error : invalid Lvalue is the error

Code:

#include<stdio.h>
main()
{
int i,arr[10];
for (i=0;i<=9;i++)
{
printf("Enter value of arr[%d] : ",i);
scanf("%d",&arr[i]);

[Code] ....

View 1 Replies View Related

C++ :: Compiler Time Checker - Invalid Application Of Size Of To Function Type

Nov 30, 2014

I have this piece of code from the book "Modern C++ Design" that checks for compile-time error. When i tried to compile it, i get the error "invalid application of size of to function type". How to make this compiler-time checker work?

Code:
template<bool> struct CompileTimeChecker{
CompileTimeChecker(...);
};
template<> struct CompileTimeChecker<false> {};

[Code] .....

View 4 Replies View Related

C/C++ :: How To Hook Function From Same Process And Get Address Of Caller Function

Apr 27, 2013

I need to do it to avoid calling a function of my process from injected code.

So would like to hook this function to check whether the call is from the current module or it is from an external module, then I compare the address of the instruction who did the call with the module address range.

View 1 Replies View Related

C++ :: Function To Determine And Print Prime Numbers

Mar 30, 2013

/* Task: create a function that determines prime number and use it to print out prime numbers from 0-50: */

Function prototype: Should return a `bool` (because it answers a yes/no question) and should take in a single int (to ask whether it's prime).

- An int greater than 2 is prime if it is not divisible by any number between 2 and itself, not including itself.
- Use this function to print out the primes less than 50. Check it against my list:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47

#include <iostream>
using namespace std;
int prime(int&x) {
if(x%2==1)

[Code] ....

It is printing out the correct prime numbers but also printing this between each number: 1629974960

View 3 Replies View Related

Visual C++ :: Determine Type In Function Template

Jul 28, 2013

I want to detect the type in a function template, like this:

template <class myType> myType Function (myType a, myType b) {
//Detect the myType
If (myType is int)

[Code] ......

Is that possible?

View 6 Replies View Related

C :: How To Call Function With Correct Arguments

Sep 13, 2013

I'm not a programmer, at least, not a good one. I'm a researcher and I need to implement this function and test it and use it for my research. I tested some clustering methods in JAVA and Matlab and also I want to test it on C. I don't know too much about programming, especially about C, I know nothing. I tried to implement some basic methods but I failed.

It's all about K-Means Algorithm. I'm working on a disease and I'm trying to find ways to early diagnosis. Anyway, these are details. The thing is, I found a 'free to use' function but I don't know how can I use it. I tried to learn something from Net, I downloaded a compiler, I paste the code and I get many errors... And I heard that I have to do some "calling function" stuff but I don't know how to..

The code is in the link below: URL....It's not imperative that using this function, it can be another one but it had to written in C.

View 13 Replies View Related

C++ :: Function Parameter Scope - NumArray Not Recognized As Valid Parameter

Sep 28, 2014

My errors are at the end of the program in two function calls within the definition of the InsertByValue function. g++ does not seem to recognize NumArray as a valid parameter.

#include <iostream>
#include <assert.h>
using namespace std;
const int CAPACITY = 20;

/* Displays the content of an int array, both the array and the size of array will be passed as parameters to the function
@param array: gives the array to be displayed
@param array_size: gives the number of elements in the array */
void DisplayArray (int array[], int array_size);

[Code] ....

View 1 Replies View Related

C++ :: Function To Determine Largest Value In Array And Then Outputs Value And Index

Dec 5, 2013

I'm trying to create a function that determines the largest value in the array and then outputs the value and index. I want to values in the array to be random so I tried using the rand function, although I'm not sure where I'm supposed to put it. My main problem (I think) is outputting the correct values...

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void lastLargestIndex (int numbers[], int arraySize);
int main(int argc, char** argv) {
int number, arraySize = 50;

[Code] ....

View 2 Replies View Related

Visual C++ :: Creating A Function That Needs To Determine Perfect Scores

Jun 24, 2013

This program is incomplete as I am having difficulty creating the function that needs to find the number of perfect scores entered by the user. I have everything but the function complete ,here is my code:

Code:
// Write a modular program that accepts at least 10 integer test scores from the user and stores them in an array.
// The main should display how many perfect scores were entered (i.e., scores of 100), using a value-returning countPerfect function.
// Input validation: Do not accept scores less than 0 or greater than 100.

#include <iostream>
using namespace std;
int countPerfect(int intArray[], int); // Function prototype

[Code] ....

View 14 Replies View Related

C :: Array Function Not Returning Correct Values

Apr 1, 2013

I have been trying to make a function that compares all the values of the array and if they are all equal will return a value to print true. The problem I am having is that regardless of what values I enter the function is always returning true. Any way to tell the program o check all the values in one command instead I put them each,

Code:
#include<stdio.h>
#include<stdlib.h>

int compare(int arrayA[], int arrayB[]);

[Code]....

View 2 Replies View Related

C++ :: Identify Correct Function Pointer From Vtable?

Jan 21, 2013

We know that function pointer for virtual function are stored in a vtable.When we have multiple function pointer entry in vtable and we call one of the virtual function then how the corresponding or correct function pointer is retrived from Vtable? Who do this stuff? In assembly code i can not see any code or logic to detrmine the correct function pointer.

View 4 Replies View Related

C :: Recursive Function Not Displaying Correct Sequence Request

Jul 1, 2013

Ok, so the assignment is to use a recursive function to display a request for a certain position in the Fibonacci Sequence (0, 1, 1, 2, 3, 5, 8, 13...)

The program I have written works, but it displays the wrong number in sequence. The book says that when you enter "8" you should receive "13", which is correct in the order of the sequence, though my program is producing "21" which is the next number in the sequence.

I tested it with a few more numbers and when I enter "7" it produces "13" and when I enter "6" it produces "8" and so on.

Code:
//Cameron Taylor
#include <stdio.h>
int main(){

[Code].....

View 2 Replies View Related

C++ :: Header And Prototype Correct But No Matching Function For Call To?

Dec 10, 2014

For whatever reason, I get an error meassage about lines 53-57 saying there is no matching function to call to. Yet the header and the prototype are correct (I think anyways).

#include <iostream>
#include <string>
#include <fstream>
#define N 10
using namespace std;
class cust{

[Code] ....

View 5 Replies View Related

C :: Correct Way To Call A Function Within Main That Has File Pointer Parameters?

Mar 16, 2013

What would be the correct way to call a function within main that has file pointer parameters?

function prototype: Code: void CalculateBoth(int num1, int num2, int*sumPtr, int *diffPtr);

View 2 Replies View Related

C/C++ :: Function To Return Either Value Or Address Of That Value?

Feb 1, 2015

I'd like a function to return either a value or the address of that value by the users input. So he can call the function like:

function("adress") - gets an adress, or function("value") - gets the value

I've tried both function overloading and templates, but none of them worked. He might input a character for the address and an int for the value... but...

Another strange thing that i observed is that the value returned by the function below is 0, so the output is address 0.

class testing
{
public:
static int x;

[Code].....

View 2 Replies View Related

C/C++ :: Find The Address Of Function?

Oct 14, 2012

find the address of function? mail the ans on (email removed)

View 4 Replies View Related

C/C++ :: How To Take Address Of Member Function

Oct 23, 2013

I want to take address of a member function in c++. How to do this.

View 2 Replies View Related







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