delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/05/17/04:00:12

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: degoble AT gtech (David. E. Goble)
Newsgroups: comp.os.msdos.djgpp
Subject: help: worked in turbo c/c++ for dos, but not in djgpp gcc
Date: Fri, 17 May 2002 05:53:40 GMT
Message-ID: <3ce499a4.67660852@news.adelaide.on.net>
X-Newsreader: Forte Free Agent 1.21/32.243
NNTP-Posting-Host: dialup-244.96.220.203.acc01-waym-adl.comindico.com.au
X-Trace: duster.adelaide.on.net 1021621043 dialup-244.96.220.203.acc01-waym-adl.comindico.com.au (17 May 2002 17:07:23 +0950)
Lines: 43
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi all;

What is wrong with this code;

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void centertext(char *stri, char *stro)
{
int st, j;
	if(strlen(stri)<=strlen(stro))
		{
		st=((strlen(stro)/2)-(strlen(stri)/2));
		for(j=0; j<strlen(stri); j++) stro[st+j]=stri[j];
		}
    else stro=stri;
    strcpy(stro, "\0");
}

int main(void)
{
char *name="myc";
char *author="David. E. Goble";
const char *title="Kangaroo Island Pistol Club - Database";
char *date="15th of May, 2002";
char *subtext1="+Program: ";
char *subtext2=" (c) by ";
char *text, *temp;

  strcpy(text, title);
 
  printf("the value of title is: %s\n", title);
  printf("the value of text is: %s\n\n", text);
  /*
  centertext(title, text);
  */
  printf("the new value of text is %s\n\n", text);

return 0;
}


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019