Skip to main content
gamedev.net
🔒 Locked

code problem

Started by Penguinzchaseme 1 reply 350+ views
Original Post
Penguinzchaseme
Penguinzchaseme
This code multiplies the number of each letter in a string(a=1 z=26) and checks to see if the modulus of each string divided by 47 is equal. #include <iostream> using namespace std; int main() { char alpha[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char UFO[7], Group[7]; int n, x, y, z, a, b=1, c=1; cin>>UFO[7]; cin>>Group[7]; for(n=0; alpha[n];n++); { for(x=0;UFO[x];x++){ if(UFO[x]=alpha[n])UFO[x]=n+1; } for(y=0;Group[y];y++) if(Group[y]=alpha[n])Group[y]=n+1; } for(z=0;UFO[z];z++){ b=b*UFO[z]; } for(a=0;GroupLink
When Penguins are chasing you, resistance is futile, give into their demands and they may spare you
krez
krez
ok
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
cmptrgear
cmptrgear
I''m not quite sure what your question is but if you expect
cin >> UFO[7];
to fill in 7 characters into the array it wont work, it will actually write into memory that isnt even in the array because UFO[7] points to memory that is 1 memory address past the end of the area. If you want a string you probably want to do
char * UFO;
cin >> UFO;
"Pfft, Facts! Facts can be used to prove anything!" -- Homer J. Simpson

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.