Beginner's Code: Input string and reverse it
Program inputs a string & prints it out backwards to a file. Found at http://users.neca.com/jboxall/ja05002.htm
AI
สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
ซอร์สโค้ด
/* Jason Boxall 1/13/97 CSC 131 Lab#5 */
/* This program inputs a name(s) and prints it(them) out backwards */
#include <stdio.h>
#include <string.h>
FILE *fout;
void main()
{
char name[20];
char *getname(); /* Fuction prototype */
void switcheroo(char *); /* Fuction prototype */
fout=fopen("a:lab5out.dat","w");
strcpy(name,getname());
while(strcmp("q",name))
{
switcheroo(name);
fprintf(fout,"\n");
strcpy(name,getname());
}
}
char *getname()
{
char name[20];
printf("\n\nEnter in a name to print backwards or 'q' to quit: ");
gets(name);
return name;
}
void switcheroo(char *name)
{
int x,i;
x=strlen(name);
for(i=(x-1);i>=0;--i)
{
putchar(name[i]);
fprintf(fout,"%c",name[i]);
}
}
Upload
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine