There are still a lot of things wrong with the code above have another look at it
but i don't think it would come up with 7 and 21 either way...
User Profile
Collapse
-
Something in C that has always bothered me.
Hi guys,
Just a quick question really regarding using strings in C.
I know that a very good way in to capture and display a string in C is to use the gets() function. I know this used to be all the rage in C but now its frowned upon and some compilers now pick upon this as a warning error.
For example if you were to write something like
[CODE="c"]printf("\nTown name: ");... -
Thanks people. It seems to have worked so far. But with C,we all know one problem can be substituted with another So I may be back with more headaches lolLeave a comment:
-
[code=c]
printf("\nHouse Name Please: ");
scanf("%s", &address.houseN ame);
gets(address.ho useName);
puts(address.ho useName);
I did this because If I comment out the scanf() statement the compiler will completely skim over the printf prompt for the house name as well as the gets() statement. The scanf statement was the only way I could stop this from...Leave a comment:
-
using gets() to output a string to a file in C
Hello all,
I am trying to read in some data which input from the keyboard which is stored using data structures. I have found a way to get this to work using the first input from the user in a set of questions in this code.
[code="c"]printf("\n\nEnt er your name: ");
gets(personalDe tails.criminalN ame);
puts(personalDe tails.criminalN ame);[/code]
Later on I have... -
Adding 2 user specified numbers.
Howdy, Looking for some help with a simple program. What do I need for a program to calculate the sum of 2 given numbers by the user.
[CODE=c]#include<stdio. h>
int main()
{
int a, b, sum;
printf("Input first integer : %s \n\n", a);
printf("Input Second integer :%s \n\n", b);
printf("The sum of the 2 values... -
I'm studying perl using the PERL for Dummies book. And have been for some time. It's the only book I can make sense of lol and has been useful .
I've seen many examples of code with a line such as
[CODE=perl]
if ($scalar =~ (/N.)S(.N)/)
[/CODE]
with a string value of nesting.
Below is the code I've edited based on your suggesstions. Now the pattern i've been trying to...Leave a comment:
-
Matching patterns on a string with 2 sets of parenthesis
[code=perl]
$greedyMatch = 'Mississippi';
if ($greedyMatch =~ /(M*)S(s*)/) #!
{ print "\n\nMatch Found :D\n" } else { print "\n\nThere was no match :(\n"};
print "$1\n$2\n";[/code]
I'm finding the problem in line 2 of this code extract. The Letter "S" from what I gather is the key that lets you define multiple expressions to match against one string. I can't... -
Getting an <STDIN> statement to work in Windows PERL Express
[code=perl]
#This is a program from dummies.com
$TheDB = 'edata.txt';
# Open the database file but quit if it doesn't exist
open(INDB, $TheDB) or die "The database $TheDB could " .
"not be found.\n";
while(1) { # Loop forever
print "\nDo you want to search by employee ID (I), " .
" or quit (Q): ";
$DoSearch = <STDIN>;... -
Running and returning a value from a subroutine
Howdy,
I've been trying to do a basic calculation in PERL using a subroutine however i'm confused about a few thing. In the following code what is the signifcants of the list variable "@_"
Secondly, How do I return a value, in this case the Literal, 2 to the perl compiler? At the moment, the code does nothing.
Thanks,
[CODE=perl]# the justAdd subroutine CH 13
... -
Hello,
Well I compared our 2 bits of code and I believe I found where the problem was
[code=perl]
@lastNames = ('Sutherland',' Summers','Sunle y','Duran','Gri eve')[/code]
In the above line there is a semi colon missing.
[code=perl]
@lastNames = ('Sutherland',' Summers','Sunle y','Duran','Gri eve');[/code]
By simply adding the semi colon to the line, both code blocks seemed...Leave a comment:
-
Using the GREP Function in PERL 5.8
I've found a program and interpreter for PERL 5.8 so to everyone who tried to help me with that thank you.
Now my attention turns to the GREP function in PERL. From what I understand GREP is a simple pattern matching function that searches for either the full element in a string or a first letter of an element, but if anyone can clarify this that would be great :)
[CODE=perl]
@lastNames = ('Sutherland',' Summers','Sunle y','Duran','Gri eve')... -
That's the main problem though. My Open Perl IDE came directly from my attempts to install Activestate.
ActivePerl
That failed. I have my perl.exe file so I can run it from my Open IDE.
I think for ActiveState the file I'm missing is the activeperl.msi file. That's why I started using Open PERL because no matter what I try ActivePERL will not install.Leave a comment:
-
Upgrading from PERL 5.6 to 5.8
Hello everyone. Bit of a general question this time around, really.
As I said previously I downloaded the compiler version of the PERL language. Having looked hard I can see that i've ended up with 5.6, having intended to actually download ActivePerl for windows. To be honest that's another story.
So now i'm on Open Perl IDE which works great for a lot of PERL programs. However of course, its not the finished article.... -
Listing values on an edited Hash
Hello People.
I have a PERL program here written on Open PERL IDE.
Is it possible to write 2 versions of a Hash list?
Lines 6 to 9 contain the orginal list.
Line 10 changes a value from 47 to 35.
6-9 How can I display the orginal list with its values and do the same for the edited hash list?
Thank you. .
[CODE=perl]
#!C:\Perl\bin\... -
-
Yea, sorry I would have deleted it earlier when i tried to preview the last one only I can't seem to find where you delete posts that you make yourself....Leave a comment:
-
Using Strict and Warnings modules.
Hello everyone. Last Friday I finally found a good compiler for PERL and the "shebang" line I think I need to run. They might not be running on a server but certainly they compiling well on my hard drive.
So that's great.
[CODE=perl]
#!C:\perl\bin\
use strict;
use warnings;
$wordCount = $wordCount +1;
$calc1 = 1+1;
$bookTitle;
$name = "Jonnie";... -
Using Strict and Warnings modules.
editing out. read the other one plsLast edited by jonniethecodeprince; Aug 25 '07, 02:47 PM. Reason: editing out. read the other one pls -
No activity results to display
Show More
Leave a comment: