dayana42200
Junior Member level 3
Hello.
Im writing a C programme that reads the files and trying the save the processed string to other file.
So the string is:
The inital coding is:
the Output of the above coding is (i have problem uploading the output image so ill just give the substring)
From the image, the code can generate 32 substring where each substring is in 115 character length from the input file. I didnt show the full generated output.
So Im tring to write the output image in a different text file.
my revised code:
and I get this:
do you guys know why?
also is it possible write those substring in different text file?
for example each of the 32 substring is written in 32 text file (subtring 1 in 1st text file, substring 2 in 2nd text file, etc ...)
Thank you in advance.
Im writing a C programme that reads the files and trying the save the processed string to other file.
So the string is:
CTGCTTGTGAATTTTCTGAGACGGATGTAACAAATACTGAACATCATCAACCCAGTAATAATGATTTGAACACCACTGAGAAGCGTGCAGCTGAGAGGCATCCAGAAAAGTATCAGGGTAGTTCTGTTTCAAACTTGCATGTGGAGCCATGTGGCACAAATACTCATGCCAGCTCATTACAGCATGAGAACAGCAGTTTATTACTCACTAAAGACAGAATGAATGTAGAAAAGGCTGAATTCTGTAATAAAAGCAAACAGCCTGGCTTAGCAAGGAGCCAACATAACAGATGGGCTGGAAGTAAGGAAACATGTAATGATAGGCGGACTCCCAGCACAGAAAAAAAGGTAGATCTGAATGCTGATCCCCTGTGTGAGAGAAAAGAATGGAATAAGCAGAAACTGCCATGCTCAGAGAATCCTAGAGATACTGAAGATGTTCCTTGGATAACACTAAATAGCAGCATTCAGAAAGTTAATGAGTGGTTTTCCAGAAGTGATGAACTGTTAGGTTCTGATGACTCACATGATGGGGAGTCTGAATCAAATGCCAAAGTAGCTGATGTATTGGACGTTCTAAATGAGGTAGATGAATATTCTGGTTCTTCAGAGAAAATAGACTTACTGGCCAGTGATCCTCATGAGGCTTTAATATGTAAAAGTGAAAGAGTTCACTCCAAATCAGTAGAGAGTAATATTGAAGACAAAATATTTGGGAAAACCTATCGGAAGAAGGCAAGCCTCCCCAACTTAAGCCATGTAACTGAAAATCTAATTATAGGAGCATTTGTTACTGAGCCACAGATAATACAAGAGCGTCCCCTCACAAATAAATTAAAGCGTAAAAGGAGACCTACATCAGGCCTTCATCCTGAGGATTTTATCAAGAAAGCAGATTTGGCAGTTCAAAAGACTCCTGAAATGATAAATCAGGGAACTAACCAAACGGAGCAGAATGGTCAAGTGATGAATATTACTAATAGTGGTCATGAGAATAAAACAAAAGGTGATTCTATTCAGAATGAGAAAAATCCTAACCCAATAGAATCACTCGAAAAAGAATCTGCTTTCAAAACGAAAGCTGAACCTATAAGCAGCAGTATAAGCAATATGGAACTCGAATTAAATATCCACAATTCAAAAGCACCTAAAAAGAATAGGCTGAGGAGGAAGTCTTCTACCAGGCATATTCATGCGCTTGAACTAGTAGTCAGTAGAAATCTAAGCCCACCTAATTGTACTGAATTGCAAATTGATAGTTGTTCTAGCAGTGAAGAGATAAAGAAAAAAAAGTACAACCAAATGCCAGTCAGGCACAGCAGAAACCTACAACTCATGGAAGGTAAAGAACCTGCAACTGGAGCCAAGAAGAGTAACAAGCCAAATGAACAGACAAGTAAAAGACATGACAGCGATACTTTCCCAGAGCTGAAGTTAACAAATGCACCTGGTTCTTTTACTAAGTGTTCAAATACCAGTGAACTTAAAGAATTTGTCAATCCTAGCCTTCCAAGAGAAGAAAAAGAAGAGAAACTAGAAACAGTTAAAGTGTCTAATAATGCTGAAGACCCCAAAGATCTCATGTTAAGTGGAGAAAGGGTTTTGCAAACTGAAAGATCTGTAGAGAGTAGCAGTATTTCATTGGTACCTGGTACTGATTATGGCACTCAGGAAAGTATCTCGTTACTGGAAGTTAGCACTCTAGGGAAGGCAAAAACAGAACCAAATAAATGTGTGAGTCAGTGTGCAGCATTTGAAAACCCCAAGGGACTAATTCATGGTTGTTCCAAAGATAATAGAAATGACACAGAAGGCTTTAAGTATCCATTGGGACATGAAGTTAACCACAGTCGGGAAACAAGCATAGAAATGGAAGAAAGTGAACTTGATGCTCAGTATTTGCAGAATACATTCAAGGTTTCAAAGCGCCAGTCATTTGCTCCGTTTTCAAATCCAGGAAATGCAGAAGAGGAATGTGCAACATTCTCTGCCCACTCTGGGTCCTTAAAGAAACAAAGTCCAAAAGTCACTTTTGAATGTGAACAAAAGGAAGAAAATCAAGGAAAGAATGAGTCTAATATCAAGCCTGTACAGACAGTTAATATCACTGCAGGCTTTCCTGTGGTTGGTCAGAAAGATAAGCCAGTTGATAATGCCAAATGTAGTATCAAAGGAGGCTCTAGGTTTTGTCTATCATCTCAGTTCAGAGGCAACGAAACTGGACTCATTACTCCAAATAAACATGGACTTTTACAAAACCCATATCGTATACCACCACTTTTTCCCATCAAGTCATTTGTTAAAACTAAATGTAAGAAAAATCTGCTAGAGGAAAACTTTGAGGAACATTCAATGTCACCTGAAAGAGAAATGGGAAATGAGAACATTCCAAGTACAGTGAGCACAATTAGCCGTAATAACATTAGAGAAAATGTTTTTAAAGAAGCCAGCTCAAGCAATATTAATGAAGTAGGTTCCAGTACTAATGAAGTGGGCTCCAGTATTAATGAAATAGGTTCCAGTGATGAAAACATTCAAGCAGAACTAGGTAGAAACAGAGGGCCAAAATTGAATGCTATGCTTAGATTAGGGGTTTTGCAACCTGAGGTCTATAAACAAAGTCTTCCTGGAAGTAATTGTAAGCATCCTGAAATAAAAAAGCAAGAATATGAAGAAGTAGTTCAGACTGTTAATACAGATTTCTCTCCATATCTGATTTCAGATAACTTAGAACAGCCTATGGGAAGTAGTCATGCATCTCAGGTTTGTTCTGAGACACCTGATGACCTGTTAGATGATGGTGAAATAAAGGAAGATACTAGTTTTGCTGAAAATGACATTAAGGAAAGTTCTGCTGTTTTTAGCAAAAGCGTCCAGAAAGGAGAGCTTAGCAGGAGTCCTAGCCCTTTCACCCATACACATTTGGCTCAGGGTTACCGAAGAGGGGCCAAGAAATTAGAGTCCTCAGAAGAGAACTTATCTAGTGAGGATGAAGAGCTTCCCTGCTTCCAACACTTGTTATTTGGTAAAGTAAACAATATACCTTCTCAGTCTACTAGGCATAGCACCGTTGCTACCGAGTGTCTGTCTAAGAACACAGAGGAGAATTTATTATCATTGAAGAATAGCTTAAATGACTGCAGTAACCAGGTAATATTGGCAAAGGCATCTCAGGAACATCACCTTAGTGAGGAAACAAAATGTTCTGCTAGCTTGTTTTCTTCACAGTGCAGTGAATTGGAAGACTTGACTGCAAATACAAACACCCAGGATCCTTTCTTGATTGGTTCTTCCAAACAAATGAGGCATCAGTCTGAAAGCCAGGGAGTTGGTCTGAGTGACAAGGAATTGGTTTCAGATGATGAAGAAAGAGGAACGGGCTTGGAAGAAAATAATCAAGAAGAGCAAAGCATGGATTCAAACTTAG
The inital coding is:
Code:
#include<stdio.h>
#include<string.h>
int main()
{
/*declare and initialise variable*/
char message[32][115],buffer[115];
int i=1;
FILE *file_in;
file_in=fopen("exon11.txt", "rb");
/*stores and prints the data from the string*/
while(fgets(buffer,115,file_in))
{
strcpy(message[i],buffer);
printf(">%d\n%s\n",i,message[i]);
i++;
}
getchar();
return 0;
the Output of the above coding is (i have problem uploading the output image so ill just give the substring)
>1
CTGCTTGTGAATTTTCTGAGACGGATGTAACAAATACTGAACATCATCAACCCAGTAATAATGATTTGAACACCACTGAGAAGCGTGCAGCTGAGAGGCATCCAGAAAAGTATC
>2
AGGGTAGTTCTGTTTCAAACTTGCATGTGGAGCCATGTGGCACAAATACTCATGCCAGCTCATTACAGCATGAGAACAGCAGTTTATTACTCACTAAAGACAGAATGAATGTAG
>3
AAAAGGCTGAATTCTGTAATAAAAGCAAACAGCCTGGCTTAGCAAGGAGCCAACATAACAGATGGGCTGGAAGTAAGGAAACATGTAATGATAGGCGGACTCCCAGCACAGAAA
From the image, the code can generate 32 substring where each substring is in 115 character length from the input file. I didnt show the full generated output.
So Im tring to write the output image in a different text file.
my revised code:
Code:
#include<stdio.h>
#include<string.h>
int main()
{
/*declare and initialise variable*/
char message[32][115],buffer[115];
int i=1;
FILE *file_in;
FILE *file_out;
file_in=fopen("exon11.txt", "rb");
file_out=fopen("1.txt", "wb");
/*stores and prints the data from the string*/
while(fgets(buffer,115,file_in))
{
strcpy(message[i],buffer);
fwrite(message,sizeof(char),sizeof(message),file_out);
}
getchar();
return 0;
and I get this:
! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F GCTGCTTGTGAATTTTCTGAGACGGATGTAACAAATACTGAACATCATCAACCCAGTAATAATGATTTGAACACCACTGAGAAGCGTGCAGCTGAGAGGCATCCAGAAAAGTATC ’ & ! Æ0 `9 R } " Ü"!a: S ~x* ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ * ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ÊOv°iOvý_ýú ˜v xî` _ýúˆð` ˆð` xî` ý_ýúpî` àø` ÊOv1!ÉŒþÿÿÿ°iOvôiOvó` l÷` lõ` ä x@UvÀQUv¨v ö` pø`
ßNv l÷` lõ` ä ´v ˜v ÁßNv,@| ˜v ? H h(((( H„„„„„„„„„„‚‚‚‚‚‚ H0´uŒw¢ÝNh v @÷` … „… „… „ ( (
… „´uŒwÜNh v ÷` ÜNhT v *÷` … „¸v ŸþÿÿŸþÿÿ$ £þÿÿXv ¸v Üÿÿÿþÿÿ… „ ¨v å … „ v ¸v Àv v $ ü v £þÿÿ£þÿÿ ( À v ¦þÿÿØÿÿÿ~þÿÿ Àv ¦v ‡þÿÿŽfŒw $ ªÜNh( … „+ …+ `ø` … „À v v Pv $ å åPv Xv @ c… Øv … $ `v `v þÿÿÿÂv Ô÷` %w¢Ý¹þÿÿÿ8÷` yIŒw ¤v ÷` v … `v Xv %wX÷` îGŒw îGŒw Ë÷` x÷` *rNv v ÷` wNv ø÷` ¨÷` Nv Ô÷` ø÷` à÷` Nvd
Nv NvÁZýú Tø` Xv pø` ÁZýú´÷` pø` ž{Tv NvNvàv `NvTø` Jvàv Xv Pv Pv 71u+`ø` rnNv v }nNvAUýú Pv –£Žw'èwÿÿÿÿ$ Lø` µÿ©\ø` }Tv lOvV:ŒwúÒNh`M| | hM| ˆbPvV:Œw’ÒNh @| (@| }Tvˆø` `ù` !ÉŒþÿÿÿºkOv }Tv ûÿÿ }TvbPv`VMvù` þúÿÿ | ôø` | ¸JvÀJv | p@ ¨ù` GhwøM| Œw Ü| VÒNh Tù` Ÿw0P@ p@ ´ù` ü@ 0P@ ’Þ ô@ @ @ ¨ù` Æ¡Žw @ @ @ ú` Vì‹w @ @ tì‹wRÑNh ! `„vŒw @ ¼ Ìù` °å‹w8ú` | ŽfŒwÈW| ´uŒwšÐNhà | ü` `„v 8@| p@ @ ‹¸Œw”ü` ŽÒNhºÙ¹¤ü` ,/’w ÿÿÿÿ* ¢ $| Èû` Äû` €<| Õ ç ÈW| ûÿÿ Ú| ´uŒw"×Nh@ | Àü` Tû` Hû` F¦Œw,Vˆw,Vˆwˆû` `¦ŒwÐNh ç ã ç ã è ,Vˆw $ý` L ^ °X| ¢ûÿÿ‡ ¢ûÿÿ¼û` ö¯Œw ÈW| ö¯Œw ¼û` B| | îÐNhÈW| À | ÈW| xû` ÈW| H DX| ȱŒwí±ŒwZ×Nhxü` ü` xü` ÈW| hM| Ðû` ü |»ŽwM· | ¨X| ü` ÈW| 0ü` ¨X| , °X| tü` È ”ˆ v ŽfŒwðv ´uŒwJÕNh v hþ` | pþ` ¸ü` ´uŒw… „ … „ˆþ` … „Z v ˜þ` … „@ … „ , … „@ îGŒw… „–£Žw$ $ÿÿÿÿŽþÿÿŽþÿÿ þÿÿðv ÿ` íÿÿÿ}þÿÿþÿÿþÿÿ¤v ’þÿÿàv V:ŒwÕNhØv v àv ¤v v | … „ À | v À v ïÿÿÿ}þÿÿ … v h … „À v …L Øv v œv èv … àv … ´þ` w ݹ Pv Tv 71u+xþ` rnNv v Pv Xv 71u+˜þ` rnNv v }nNv¹Sýú Pv –£Žw'èwÿÿÿÿ$ „þ` µÿ©”þ` €@ P@ lOv\v ¬þ` mPvCUvìþ` ˆbPv ÃkOvºkOvÍSýú€@ €@ P@ Àþ` øþ` Ìÿ` ÊOv!ÉŒþÿÿÿºkOv*lOvP@ ”ÿ` ®@ P@ ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F GAGGGTAGTTCTGTTTCAAACTTGCATGTGGAGCCATGTGGCACAAATACTCATGCCAGCTCATTACAGCATGAGAACAGCAGTTTATTACTCACTAAAGACAGAATGAATGTAG
do you guys know why?
also is it possible write those substring in different text file?
for example each of the 32 substring is written in 32 text file (subtring 1 in 1st text file, substring 2 in 2nd text file, etc ...)
Thank you in advance.
Last edited by a moderator: